feat: add back json ld
This commit is contained in:
		| @@ -79,6 +79,13 @@ export default async function Page({ params }: { params: { slug: string[] } }) { | ||||
|     return coreContent(authorResults as Authors) | ||||
|   }) | ||||
|   const mainContent = coreContent(post) | ||||
|   const jsonLd = post.structuredData | ||||
|   jsonLd['author'] = authorDetails.map((author) => { | ||||
|     return { | ||||
|       '@type': 'Person', | ||||
|       name: author.name, | ||||
|     } | ||||
|   }) | ||||
|  | ||||
|   return ( | ||||
|     <> | ||||
| @@ -92,9 +99,14 @@ export default async function Page({ params }: { params: { slug: string[] } }) { | ||||
|           </PageTitle> | ||||
|         </div> | ||||
|       ) : ( | ||||
|         <PostLayout content={mainContent} authorDetails={authorDetails} next={next} prev={prev}> | ||||
|           <Mdx code={post.body.code} toc={post.toc} /> | ||||
|         </PostLayout> | ||||
|         <> | ||||
|           <script type="application/ld+json" suppressHydrationWarning> | ||||
|             {JSON.stringify(jsonLd)} | ||||
|           </script> | ||||
|           <PostLayout content={mainContent} authorDetails={authorDetails} next={next} prev={prev}> | ||||
|             <Mdx code={post.body.code} toc={post.toc} /> | ||||
|           </PostLayout> | ||||
|         </> | ||||
|       )} | ||||
|     </> | ||||
|   ) | ||||
|   | ||||
| @@ -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(() => ({ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user