We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 80377d9 + 91aa33d commit 1d5a6feCopy full SHA for 1d5a6fe
1 file changed
src/utils/seo.ts
@@ -0,0 +1,21 @@
1
+// SEO utility for structured data
2
+export function generateStructuredData(
3
+ type: string,
4
+ data: Record<string, unknown>,
5
+): string {
6
+ const schema = { "@context": "https://schema.org", "@type": type, ...data };
7
+ return JSON.stringify(schema);
8
+}
9
+
10
+export function generateBreadcrumbSchema(
11
+ items: { name: string; url: string }[],
12
13
+ return generateStructuredData("BreadcrumbList", {
14
+ itemListElement: items.map((item, i) => ({
15
+ "@type": "ListItem",
16
+ position: i + 1,
17
+ name: item.name,
18
+ item: item.url,
19
+ })),
20
+ });
21
0 commit comments