mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-31 15:29:32 +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 truncatedPost = !isBlogPostPage && truncated;
|
||||
const tagsExists = tags.length > 0;
|
||||
const TitleHeading = isBlogPostPage ? 'h1' : 'h2';
|
||||
|
||||
const renderPostHeader = () => {
|
||||
const TitleHeading = isBlogPostPage ? 'h1' : 'h2';
|
||||
|
||||
return (
|
||||
return (
|
||||
<article
|
||||
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
|
||||
itemProp="blogPost"
|
||||
itemScope
|
||||
itemType="http://schema.org/BlogPosting">
|
||||
<header>
|
||||
<TitleHeading className={styles.blogPostTitle} itemProp="headline">
|
||||
{isBlogPostPage ? (
|
||||
|
@ -94,16 +97,6 @@ function BlogPostItem(props: Props): JSX.Element {
|
|||
</div>
|
||||
<BlogPostAuthors authors={authors} assets={assets} />
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<article
|
||||
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
|
||||
itemProp="blogPost"
|
||||
itemScope
|
||||
itemType="http://schema.org/BlogPosting">
|
||||
{renderPostHeader()}
|
||||
|
||||
{image && (
|
||||
<meta itemProp="image" content={withBaseUrl(image, {absolute: true})} />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue