31 lines
780 B
TypeScript
31 lines
780 B
TypeScript
import { type Locale } from '@/i18n/config';
|
|
|
|
export function BreadcrumbJsonLd({
|
|
items,
|
|
locale,
|
|
}: {
|
|
items: { name: string; url: string }[];
|
|
locale: Locale;
|
|
}) {
|
|
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://damjan-savic.com';
|
|
|
|
const schema = {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'BreadcrumbList',
|
|
inLanguage: locale === 'de' ? 'de-DE' : locale === 'sr' ? 'sr-RS' : 'en-US',
|
|
itemListElement: items.map((item, index) => ({
|
|
'@type': 'ListItem',
|
|
position: index + 1,
|
|
name: item.name,
|
|
item: item.url.startsWith('http') ? item.url : `${baseUrl}${item.url}`,
|
|
})),
|
|
};
|
|
|
|
return (
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
|
|
/>
|
|
);
|
|
}
|