From ee6882650e73364f64f7e53806e69cc7471832f5 Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Tue, 17 Aug 2021 13:21:25 +0300 Subject: [PATCH] refactor: add blog microdata in markup instead of use JSON-LD (#5355) * refactor: add blog microdata in markup intead of use JSON-LD * Add check for authorTitle --- .../src/theme/BlogLayout/index.tsx | 4 +- .../src/theme/BlogPostItem/index.tsx | 63 ++++++++++++++----- .../src/theme/BlogPostPage/index.tsx | 6 -- .../theme/BlogPostStructuredData/index.tsx | 47 -------------- .../docusaurus-theme-classic/src/types.d.ts | 18 ------ 5 files changed, 51 insertions(+), 87 deletions(-) delete mode 100644 packages/docusaurus-theme-classic/src/theme/BlogPostStructuredData/index.tsx diff --git a/packages/docusaurus-theme-classic/src/theme/BlogLayout/index.tsx b/packages/docusaurus-theme-classic/src/theme/BlogLayout/index.tsx index f99aa4c5f2f9..e5c29fcdc03e 100644 --- a/packages/docusaurus-theme-classic/src/theme/BlogLayout/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/BlogLayout/index.tsx @@ -31,7 +31,9 @@ function BlogLayout(props: Props): JSX.Element { className={clsx('col', { 'col--7': hasSidebar, 'col--9 col--offset-1': !hasSidebar, - })}> + })} + itemScope + itemType="http://schema.org/Blog"> {children} {toc && ( diff --git a/packages/docusaurus-theme-classic/src/theme/BlogPostItem/index.tsx b/packages/docusaurus-theme-classic/src/theme/BlogPostItem/index.tsx index 7ed64193b359..325b559c4600 100644 --- a/packages/docusaurus-theme-classic/src/theme/BlogPostItem/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/BlogPostItem/index.tsx @@ -10,6 +10,7 @@ import clsx from 'clsx'; import {MDXProvider} from '@mdx-js/react'; import Translate, {translate} from '@docusaurus/Translate'; import Link from '@docusaurus/Link'; +import {useBaseUrlUtils} from '@docusaurus/useBaseUrl'; import {usePluralForm} from '@docusaurus/theme-common'; import MDXComponents from '@theme/MDXComponents'; import Seo from '@theme/Seo'; @@ -40,6 +41,7 @@ function useReadingTimePlural() { function BlogPostItem(props: Props): JSX.Element { const readingTimePlural = useReadingTimePlural(); + const {withBaseUrl} = useBaseUrlUtils(); const { children, frontMatter, @@ -74,11 +76,19 @@ function BlogPostItem(props: Props): JSX.Element { return (
- - {isBlogPostPage ? title : {title}} + + {isBlogPostPage ? ( + title + ) : ( + + {title} + + )}
- + {readingTime && ( <> @@ -93,16 +103,25 @@ function BlogPostItem(props: Props): JSX.Element { {author} )} -
- {author && ( - <> -
- {author} -
- {authorTitle} - - )} -
+ {author && ( + + )}
); @@ -112,11 +131,24 @@ function BlogPostItem(props: Props): JSX.Element { <> -
+
{renderPostHeader()} -
+ + {image && ( + + )} + +
{children}
+ {(tags.length > 0 || truncated) && (