Skip to content

Commit

Permalink
feat: support author as a blog's metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagi-ovo committed Aug 26, 2024
1 parent 5aa7047 commit 1da0fa9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/components/Seo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -20,6 +21,7 @@ type SeoProps = {
banner?: string;
canonical?: string;
tags?: string;
author?: string;
} & Partial<typeof defaultMeta>;

export default function Seo(props: SeoProps) {
Expand Down Expand Up @@ -113,6 +115,7 @@ export default function Seo(props: SeoProps) {
content='/favicon/ms-icon-144x144.png'
/>
<meta name='theme-color' content='#ffffff' />
<meta name='author' content={meta.author || defaultMeta.author} />
</Head>
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/blog/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export default function SingleBlogPage({
).toISOString()}
canonical={frontmatter.repost}
tags={frontmatter.tags}
author={frontmatter.author}
/>

<main>
Expand All @@ -127,8 +128,8 @@ export default function SingleBlogPage({

<p className='mt-2 text-sm text-gray-600 dark:text-gray-300'>
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'}.
</p>
{frontmatter.lastUpdated && (
<div className='mt-2 flex flex-wrap gap-2 text-sm text-gray-700 dark:text-gray-200'>
Expand Down
1 change: 1 addition & 0 deletions src/types/frontmatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type BlogFrontmatter = {
lastUpdated?: string;
tags: string;
repost?: string;
author?: string;
};

export type ContentType = 'blog' | 'library' | 'projects';
Expand Down

0 comments on commit 1da0fa9

Please sign in to comment.