1
0
Fork 0
blog/src/components/layouts/Base/SchemaOrg.astro

53 lines
1.1 KiB
Plaintext

---
import config from '@config/blog.config'
export type Props = {
title: string
url: string
image: string
description: string
datePublished?: string
dateModified?: string
}
const { title, url, image, description, datePublished, dateModified } =
Astro.props
const { siteUrl, siteTitle, author } = config
const schema = datePublished
? {
'@context': 'http://schema.org',
'@type': 'BlogPosting',
author: {
'@type': 'Person',
name: author.name,
url: author.url
},
publisher: {
'@type': 'Organization',
name: author.name
},
url,
headline: title,
image: {
'@type': 'ImageObject',
url: image
},
description,
datePublished,
dateModified: dateModified || datePublished,
mainEntityOfPage: {
'@type': 'Blog',
'@id': siteUrl
}
}
: {
'@context': 'http://schema.org',
'@type': 'Blog',
url: siteUrl,
name: siteTitle
}
---
<script type="application/ld+json" set:html={JSON.stringify(schema)} />