mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 02:08:55 +02:00
refactor(theme-classic): render BlogPostItem as one JSX element (#6436)
This commit is contained in:
parent
64909e7f14
commit
c2e2938d1b
1 changed files with 7 additions and 14 deletions
|
@ -65,11 +65,14 @@ function BlogPostItem(props: Props): JSX.Element {
|
||||||
const image = assets.image ?? frontMatter.image;
|
const image = assets.image ?? frontMatter.image;
|
||||||
const truncatedPost = !isBlogPostPage && truncated;
|
const truncatedPost = !isBlogPostPage && truncated;
|
||||||
const tagsExists = tags.length > 0;
|
const tagsExists = tags.length > 0;
|
||||||
|
const TitleHeading = isBlogPostPage ? 'h1' : 'h2';
|
||||||
|
|
||||||
const renderPostHeader = () => {
|
return (
|
||||||
const TitleHeading = isBlogPostPage ? 'h1' : 'h2';
|
<article
|
||||||
|
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
|
||||||
return (
|
itemProp="blogPost"
|
||||||
|
itemScope
|
||||||
|
itemType="http://schema.org/BlogPosting">
|
||||||
<header>
|
<header>
|
||||||
<TitleHeading className={styles.blogPostTitle} itemProp="headline">
|
<TitleHeading className={styles.blogPostTitle} itemProp="headline">
|
||||||
{isBlogPostPage ? (
|
{isBlogPostPage ? (
|
||||||
|
@ -94,16 +97,6 @@ function BlogPostItem(props: Props): JSX.Element {
|
||||||
</div>
|
</div>
|
||||||
<BlogPostAuthors authors={authors} assets={assets} />
|
<BlogPostAuthors authors={authors} assets={assets} />
|
||||||
</header>
|
</header>
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<article
|
|
||||||
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
|
|
||||||
itemProp="blogPost"
|
|
||||||
itemScope
|
|
||||||
itemType="http://schema.org/BlogPosting">
|
|
||||||
{renderPostHeader()}
|
|
||||||
|
|
||||||
{image && (
|
{image && (
|
||||||
<meta itemProp="image" content={withBaseUrl(image, {absolute: true})} />
|
<meta itemProp="image" content={withBaseUrl(image, {absolute: true})} />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue