26 lines
600 B
TypeScript
26 lines
600 B
TypeScript
interface BreadcrumbSchemaItem {
|
|
position: number;
|
|
name: string;
|
|
item: string;
|
|
}
|
|
|
|
export function BreadcrumbsSchema({ items }: { items: BreadcrumbSchemaItem[] }) {
|
|
const structuredData = {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'BreadcrumbList',
|
|
itemListElement: items.map((item) => ({
|
|
'@type': 'ListItem',
|
|
position: item.position,
|
|
name: item.name,
|
|
item: `http://localhost:3000${item.item}`,
|
|
})),
|
|
};
|
|
|
|
return (
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}
|
|
/>
|
|
);
|
|
}
|