Skip to content

Commit

Permalink
feat: implement in BlogPostPage-remove Seo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyreilly committed Aug 19, 2021
1 parent 88e6d74 commit 1cba459
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ declare module '@theme/Seo' {
readonly description?: string;
readonly keywords?: readonly string[] | string;
readonly image?: string;
readonly children?: ReactNode;
};

const Seo: (props: Props) => JSX.Element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,7 @@ function BlogPostItem(props: Props): JSX.Element {

return (
<>
{isBlogPostPage ? (
<Seo {...{keywords, image}}>
<meta property="og:type" content="article" />
<meta property="article:published_time" content={date} />
{authorURL && <meta property="article:author" content={authorURL} />}
{frontMatter.tags && (
<meta property="article:tag" content={frontMatter.tags.join(',')} />
)}
</Seo>
) : (
<Seo {...{keywords, image}} />
)}
<Seo {...{keywords, image}} />

<article
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import BlogPostItem from '@theme/BlogPostItem';
import BlogPostPaginator from '@theme/BlogPostPaginator';
import type {Props} from '@theme/BlogPostPage';
import {ThemeClassNames} from '@docusaurus/theme-common';
import Head from '@docusaurus/Head';

function BlogPostPage(props: Props): JSX.Element {
const {content: BlogPostContents, sidebar} = props;
const {frontMatter, frontMatterAssets, metadata} = BlogPostContents;
const {title, description, nextItem, prevItem} = metadata;
const {title, description, nextItem, prevItem, date} = metadata;
const {hide_table_of_contents: hideTableOfContents} = frontMatter;
const authorURL = frontMatter.author_url || frontMatter.authorURL;

return (
<BlogLayout
Expand All @@ -30,6 +32,14 @@ function BlogPostPage(props: Props): JSX.Element {
? BlogPostContents.toc
: undefined
}>
<Head>
<meta property="og:type" content="article" />
<meta property="article:published_time" content={date} />
{authorURL && <meta property="article:author" content={authorURL} />}
{frontMatter.tags && (
<meta property="article:tag" content={frontMatter.tags.join(',')} />
)}
</Head>
<BlogPostItem
frontMatter={frontMatter}
frontMatterAssets={frontMatterAssets}
Expand Down
2 changes: 0 additions & 2 deletions packages/docusaurus-theme-classic/src/theme/Seo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default function Seo({
description,
keywords,
image,
children,
}: Props): JSX.Element {
const {image: defaultImage} = useThemeConfig();
const pageTitle = useTitleFormatter(title);
Expand All @@ -42,7 +41,6 @@ export default function Seo({

{pageImage && <meta property="og:image" content={pageImage} />}
{pageImage && <meta name="twitter:image" content={pageImage} />}
{children}
</Head>
);
}

0 comments on commit 1cba459

Please sign in to comment.