mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-14 00:32:47 +02:00
feat: different implementation
This commit is contained in:
parent
29afb64445
commit
84bf24c69b
3 changed files with 11 additions and 19 deletions
|
@ -132,7 +132,7 @@ declare module '@theme/Seo' {
|
||||||
readonly description?: string;
|
readonly description?: string;
|
||||||
readonly keywords?: readonly string[] | string;
|
readonly keywords?: readonly string[] | string;
|
||||||
readonly image?: string;
|
readonly image?: string;
|
||||||
readonly metaTags?: Record<string, string>;
|
readonly children?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Seo: (props: Props) => JSX.Element;
|
const Seo: (props: Props) => JSX.Element;
|
||||||
|
|
|
@ -127,20 +127,16 @@ function BlogPostItem(props: Props): JSX.Element {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const metaTags = isBlogPostPage
|
|
||||||
? {
|
|
||||||
'og:type': 'article',
|
|
||||||
'article:published_time': date,
|
|
||||||
...(authorURL ? {'article:author': authorURL} : {}),
|
|
||||||
...(frontMatter.tags
|
|
||||||
? {'article:tag': frontMatter.tags.join(',')}
|
|
||||||
: {}),
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Seo {...{keywords, image, metaTags}} />
|
<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>
|
||||||
|
|
||||||
<article
|
<article
|
||||||
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
|
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default function Seo({
|
||||||
description,
|
description,
|
||||||
keywords,
|
keywords,
|
||||||
image,
|
image,
|
||||||
metaTags,
|
children,
|
||||||
}: Props): JSX.Element {
|
}: Props): JSX.Element {
|
||||||
const {image: defaultImage} = useThemeConfig();
|
const {image: defaultImage} = useThemeConfig();
|
||||||
const pageTitle = useTitleFormatter(title);
|
const pageTitle = useTitleFormatter(title);
|
||||||
|
@ -28,11 +28,6 @@ export default function Seo({
|
||||||
{title && <title>{pageTitle}</title>}
|
{title && <title>{pageTitle}</title>}
|
||||||
{title && <meta property="og:title" content={pageTitle} />}
|
{title && <meta property="og:title" content={pageTitle} />}
|
||||||
|
|
||||||
{metaTags &&
|
|
||||||
Object.entries(metaTags).map(([property, content]) => (
|
|
||||||
<meta key={property} property={property} content={content} />
|
|
||||||
))}
|
|
||||||
|
|
||||||
{description && <meta name="description" content={description} />}
|
{description && <meta name="description" content={description} />}
|
||||||
{description && <meta property="og:description" content={description} />}
|
{description && <meta property="og:description" content={description} />}
|
||||||
|
|
||||||
|
@ -47,6 +42,7 @@ export default function Seo({
|
||||||
|
|
||||||
{pageImage && <meta property="og:image" content={pageImage} />}
|
{pageImage && <meta property="og:image" content={pageImage} />}
|
||||||
{pageImage && <meta name="twitter:image" content={pageImage} />}
|
{pageImage && <meta name="twitter:image" content={pageImage} />}
|
||||||
|
{children}
|
||||||
</Head>
|
</Head>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue