Skip to content

The open alternative to Salesforce, designed for AI.

550 B
Raw Blame
import { type I18n } from '@lingui/core';
import { type MessageDescriptor } from '@lingui/core';

type FaqEntry = { question: MessageDescriptor; answer: MessageDescriptor };

export const buildFaqPageJsonLd = (
  i18n: I18n,
  questions: readonly FaqEntry[],
): Record<string, unknown> => ({
  '@context': 'https://schema.org',
  '@type': 'FAQPage',
  mainEntity: questions.map((entry) => ({
    '@type': 'Question',
    name: i18n._(entry.question),
    acceptedAnswer: {
      '@type': 'Answer',
      text: i18n._(entry.answer),
    },
  })),
});