upstream #1

Merged
jblu merged 1007 commits from upstream into main 2024-11-04 22:35:57 -06:00
2 changed files with 33 additions and 4 deletions
Showing only changes of commit 202fa62b3f - Show all commits

View File

@ -79,6 +79,13 @@ export default async function Page({ params }: { params: { slug: string[] } }) {
return coreContent(authorResults as Authors) return coreContent(authorResults as Authors)
}) })
const mainContent = coreContent(post) const mainContent = coreContent(post)
const jsonLd = post.structuredData
jsonLd['author'] = authorDetails.map((author) => {
return {
'@type': 'Person',
name: author.name,
}
})
return ( return (
<> <>
@ -92,9 +99,14 @@ export default async function Page({ params }: { params: { slug: string[] } }) {
</PageTitle> </PageTitle>
</div> </div>
) : ( ) : (
<>
<script type="application/ld+json" suppressHydrationWarning>
{JSON.stringify(jsonLd)}
</script>
<PostLayout content={mainContent} authorDetails={authorDetails} next={next} prev={prev}> <PostLayout content={mainContent} authorDetails={authorDetails} next={next} prev={prev}>
<Mdx code={post.body.code} toc={post.toc} /> <Mdx code={post.body.code} toc={post.toc} />
</PostLayout> </PostLayout>
</>
)} )}
</> </>
) )

View File

@ -17,6 +17,7 @@ import rehypeKatex from 'rehype-katex'
import rehypeCitation from 'rehype-citation' import rehypeCitation from 'rehype-citation'
import rehypePrismPlus from 'rehype-prism-plus' import rehypePrismPlus from 'rehype-prism-plus'
import rehypePresetMinify from 'rehype-preset-minify' import rehypePresetMinify from 'rehype-preset-minify'
import siteMetadata from './data/siteMetadata'
const root = process.cwd() const root = process.cwd()
@ -54,7 +55,23 @@ export const Blog = defineDocumentType(() => ({
bibliography: { type: 'string' }, bibliography: { type: 'string' },
canonicalUrl: { 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(() => ({ export const Authors = defineDocumentType(() => ({