Skip to content

Commit 91aa33d

Browse files
committed
feat(seo): add structured data generation utilities
1 parent 80377d9 commit 91aa33d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/utils/seo.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
): string {
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

Comments
 (0)