30 lines
708 B
TypeScript
30 lines
708 B
TypeScript
import { type Locale } from '@/i18n/config';
|
|
|
|
interface FAQItem {
|
|
question: string;
|
|
answer: string;
|
|
}
|
|
|
|
export function FAQJsonLd({ items, locale }: { items: FAQItem[]; locale?: Locale }) {
|
|
const schema = {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'FAQPage',
|
|
inLanguage: locale ? (locale === 'de' ? 'de-DE' : locale === 'sr' ? 'sr-RS' : 'en-US') : 'de-DE',
|
|
mainEntity: items.map((item) => ({
|
|
'@type': 'Question',
|
|
name: item.question,
|
|
acceptedAnswer: {
|
|
'@type': 'Answer',
|
|
text: item.answer,
|
|
},
|
|
})),
|
|
};
|
|
|
|
return (
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
|
|
/>
|
|
);
|
|
}
|