39 lines
912 B
TypeScript
39 lines
912 B
TypeScript
import { Head, usePage } from "@inertiajs/react";
|
|
import { ReactNode } from "react";
|
|
|
|
interface BreadcrumbItem {
|
|
title: string;
|
|
url: string;
|
|
}
|
|
|
|
interface AppLayoutProps {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export default function AppLayout({ children }: AppLayoutProps) {
|
|
const { breadcrumbs } = usePage().props as {
|
|
breadcrumbs?: BreadcrumbItem[];
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
{breadcrumbs?.length > 0 && (
|
|
<script type="application/ld+json">
|
|
{JSON.stringify({
|
|
"@context": "https://schema.org",
|
|
"@type": "BreadcrumbList",
|
|
itemListElement: breadcrumbs.map((crumb, index) => ({
|
|
"@type": "ListItem",
|
|
position: index + 1,
|
|
name: crumb.title,
|
|
item: crumb.url,
|
|
})),
|
|
})}
|
|
</script>
|
|
)}
|
|
</Head>
|
|
{children}
|
|
</>
|
|
);
|
|
}
|