🪛 03 routing
This commit is contained in:
33
lib/seo.ts
Normal file
33
lib/seo.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
export interface SEOData {
|
||||
title: string
|
||||
description: string
|
||||
url: string
|
||||
image?: string
|
||||
type?: 'website' | 'article'
|
||||
author?: string
|
||||
publishedTime?: string
|
||||
}
|
||||
|
||||
export function generateStructuredData(data: SEOData) {
|
||||
const structuredData: any = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': data.type === 'article' ? 'BlogPosting' : 'WebSite',
|
||||
headline: data.title,
|
||||
description: data.description,
|
||||
url: data.url,
|
||||
}
|
||||
|
||||
if (data.image) {
|
||||
structuredData.image = data.image
|
||||
}
|
||||
|
||||
if (data.type === 'article') {
|
||||
structuredData.author = {
|
||||
'@type': 'Person',
|
||||
name: data.author || 'Unknown',
|
||||
}
|
||||
structuredData.datePublished = data.publishedTime
|
||||
}
|
||||
|
||||
return JSON.stringify(structuredData)
|
||||
}
|
||||
Reference in New Issue
Block a user