--- import { getPublication } from '../utils/publication'; import { faqItemsFromSourceHtml, faqPageSchema, serializeJsonLd, type FAQItem } from '../utils/structured-data'; interface Props { label?: string; heading: string; items?: FAQItem[]; canonical?: string; variant?: 'blog' | 'source' | 'page'; sourceSelector?: string; sourceHtml?: string; searchSelector?: string; faqIconColor?: string; } const { label, heading, items = [], canonical, variant = 'blog', sourceSelector, sourceHtml, searchSelector, faqIconColor = '--color-accent-strong' } = Astro.props; const resolvedFaqIconColor = faqIconColor.startsWith('--') ? `var(${faqIconColor})` : faqIconColor; const headingId = variant === 'page' ? 'faq-questions-heading' : label ? 'blog-faq-heading' : 'source-faq-heading'; const publication = await getPublication(Astro.url.pathname); if (canonical && canonical.replace(/\/$/, '') !== publication.canonical.replace(/\/$/, '')) { throw new Error(`FAQ canonical disagrees with publication policy: ${publication.route}`); } if ((sourceSelector && items.length) || (sourceHtml !== undefined && !sourceSelector)) { throw new Error('FAQ items and runtime source content must not be mixed'); } const schemaItems = sourceSelector ? sourceHtml === undefined ? [] : faqItemsFromSourceHtml(sourceHtml) : items; const schema = faqPageSchema(schemaItems, publication); // Locals belong to this render request, not a module-level build-wide registry. const state = Astro.locals as { aiaFaqSchemaClaimed?: boolean }; if (schema) { if (state.aiaFaqSchemaClaimed) throw new Error(`Multiple FAQ schemas: consolidate accordions on ${publication.route}`); state.aiaFaqSchemaClaimed = true; } ---
{label &&

{label}

} {variant === 'page' ?

{heading}

:

{heading}

}
{items.map((item, index) => (
{item.question}
${item.answer}

`} />
))}
{schema &&