feat: add back json ld

This commit is contained in:
Timothy Lin
2023-07-09 23:09:07 +08:00
parent fab1ead77b
commit 202fa62b3f
2 changed files with 33 additions and 4 deletions
+18 -1
View File
@@ -17,6 +17,7 @@ import rehypeKatex from 'rehype-katex'
import rehypeCitation from 'rehype-citation'
import rehypePrismPlus from 'rehype-prism-plus'
import rehypePresetMinify from 'rehype-preset-minify'
import siteMetadata from './data/siteMetadata'
const root = process.cwd()
@@ -54,7 +55,23 @@ export const Blog = defineDocumentType(() => ({
bibliography: { type: 'string' },
canonicalUrl: { type: 'string' },
},
computedFields,
computedFields: {
...computedFields,
structuredData: {
type: 'json',
resolve: (doc) => ({
'@context': 'https://schema.org',
'@type': 'BlogPosting',
headline: doc.title,
datePublished: doc.date,
dateModified: doc.lastmod || doc.date,
description: doc.summary,
image: doc.images ? doc.images[0] : siteMetadata.socialBanner,
url: `${siteMetadata.siteUrl}/${doc._raw.flattenedPath}`,
author: doc.authors,
}),
},
},
}))
export const Authors = defineDocumentType(() => ({