From 1da0fa91839cbe94d2e0982df40d68ec4ed77271 Mon Sep 17 00:00:00 2001 From: Nagi-ovo <13264500190@163.com> Date: Mon, 26 Aug 2024 20:13:26 +0800 Subject: [PATCH] feat: support author as a blog's metadata --- src/components/Seo.tsx | 3 +++ src/pages/blog/[...slug].tsx | 5 +++-- src/types/frontmatters.ts | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Seo.tsx b/src/components/Seo.tsx index 5f108d8..5943822 100644 --- a/src/components/Seo.tsx +++ b/src/components/Seo.tsx @@ -11,6 +11,7 @@ const defaultMeta = { image: 'https://bjut-swift.cn/favicon/large-og.jpg', type: 'website', robots: 'follow, index', + author: 'BJUT SWIFT', }; type SeoProps = { @@ -20,6 +21,7 @@ type SeoProps = { banner?: string; canonical?: string; tags?: string; + author?: string; } & Partial; export default function Seo(props: SeoProps) { @@ -113,6 +115,7 @@ export default function Seo(props: SeoProps) { content='/favicon/ms-icon-144x144.png' /> + ); } diff --git a/src/pages/blog/[...slug].tsx b/src/pages/blog/[...slug].tsx index f3a1525..503df6d 100644 --- a/src/pages/blog/[...slug].tsx +++ b/src/pages/blog/[...slug].tsx @@ -108,6 +108,7 @@ export default function SingleBlogPage({ ).toISOString()} canonical={frontmatter.repost} tags={frontmatter.tags} + author={frontmatter.author} />
@@ -127,8 +128,8 @@ export default function SingleBlogPage({

Written on{' '} - {format(new Date(frontmatter.publishedAt), 'MMMM dd, yyyy')} by - BJUT Swift. + {format(new Date(frontmatter.publishedAt), 'MMMM dd, yyyy')} by{' '} + {frontmatter.author || 'BJUT Swift'}.

{frontmatter.lastUpdated && (
diff --git a/src/types/frontmatters.ts b/src/types/frontmatters.ts index bdbfc38..11b40cc 100644 --- a/src/types/frontmatters.ts +++ b/src/types/frontmatters.ts @@ -12,6 +12,7 @@ export type BlogFrontmatter = { lastUpdated?: string; tags: string; repost?: string; + author?: string; }; export type ContentType = 'blog' | 'library' | 'projects';