66 */
77
88import React from 'react' ;
9- import Seo from '@theme/Seo' ;
109import BlogLayout from '@theme/BlogLayout' ;
1110import BlogPostItem from '@theme/BlogPostItem' ;
1211import BlogPostPaginator from '@theme/BlogPostPaginator' ;
1312import type { Props } from '@theme/BlogPostPage' ;
14- import { ThemeClassNames } from '@docusaurus/theme-common' ;
13+ import {
14+ PageMetadata ,
15+ HtmlClassNameProvider ,
16+ ThemeClassNames ,
17+ } from '@docusaurus/theme-common' ;
1518import TOC from '@theme/TOC' ;
19+ import clsx from 'clsx' ;
1620
17- export default function BlogPostPage ( props : Props ) : JSX . Element {
21+ function BlogPostPageMetadata ( props : Props ) : JSX . Element {
22+ const { content : BlogPostContents } = props ;
23+ const { assets, metadata} = BlogPostContents ;
24+ const { title, description, date, tags, authors, frontMatter} = metadata ;
25+ const { keywords} = frontMatter ;
26+ const image = assets . image ?? frontMatter . image ;
27+ return (
28+ < PageMetadata
29+ title = { title }
30+ description = { description }
31+ keywords = { keywords }
32+ image = { image } >
33+ < meta property = "og:type" content = "article" />
34+ < meta property = "article:published_time" content = { date } />
35+ { /* TODO double check those article meta array syntaxes, see https://ogp.me/#array */ }
36+ { authors . some ( ( author ) => author . url ) && (
37+ < meta
38+ property = "article:author"
39+ content = { authors
40+ . map ( ( author ) => author . url )
41+ . filter ( Boolean )
42+ . join ( ',' ) }
43+ />
44+ ) }
45+ { tags . length > 0 && (
46+ < meta
47+ property = "article:tag"
48+ content = { tags . map ( ( tag ) => tag . label ) . join ( ',' ) }
49+ />
50+ ) }
51+ </ PageMetadata >
52+ ) ;
53+ }
54+
55+ function BlogPostPageContent ( props : Props ) : JSX . Element {
1856 const { content : BlogPostContents , sidebar} = props ;
1957 const { assets, metadata} = BlogPostContents ;
20- const {
21- title,
22- description,
23- nextItem,
24- prevItem,
25- date,
26- tags,
27- authors,
28- frontMatter,
29- } = metadata ;
58+ const { nextItem, prevItem, frontMatter} = metadata ;
3059 const {
3160 hide_table_of_contents : hideTableOfContents ,
32- keywords,
3361 toc_min_heading_level : tocMinHeadingLevel ,
3462 toc_max_heading_level : tocMaxHeadingLevel ,
3563 } = frontMatter ;
36-
37- const image = assets . image ?? frontMatter . image ;
38-
3964 return (
4065 < BlogLayout
41- wrapperClassName = { ThemeClassNames . wrapper . blogPages }
42- pageClassName = { ThemeClassNames . page . blogPostPage }
4366 sidebar = { sidebar }
4467 toc = {
4568 ! hideTableOfContents &&
@@ -52,35 +75,6 @@ export default function BlogPostPage(props: Props): JSX.Element {
5275 />
5376 ) : undefined
5477 } >
55- < Seo
56- // TODO refactor needed: it's a bit annoying but Seo MUST be inside
57- // BlogLayout, otherwise default image (set by BlogLayout) would shadow
58- // the custom blog post image
59- title = { title }
60- description = { description }
61- keywords = { keywords }
62- image = { image } >
63- < meta property = "og:type" content = "article" />
64- < meta property = "article:published_time" content = { date } />
65-
66- { /* TODO double check those article meta array syntaxes, see https://ogp.me/#array */ }
67- { authors . some ( ( author ) => author . url ) && (
68- < meta
69- property = "article:author"
70- content = { authors
71- . map ( ( author ) => author . url )
72- . filter ( Boolean )
73- . join ( ',' ) }
74- />
75- ) }
76- { tags . length > 0 && (
77- < meta
78- property = "article:tag"
79- content = { tags . map ( ( tag ) => tag . label ) . join ( ',' ) }
80- />
81- ) }
82- </ Seo >
83-
8478 < BlogPostItem
8579 frontMatter = { frontMatter }
8680 assets = { assets }
@@ -95,3 +89,16 @@ export default function BlogPostPage(props: Props): JSX.Element {
9589 </ BlogLayout >
9690 ) ;
9791}
92+
93+ export default function BlogPostPage ( props : Props ) : JSX . Element {
94+ return (
95+ < HtmlClassNameProvider
96+ className = { clsx (
97+ ThemeClassNames . wrapper . blogPages ,
98+ ThemeClassNames . page . blogPostPage ,
99+ ) } >
100+ < BlogPostPageMetadata { ...props } />
101+ < BlogPostPageContent { ...props } />
102+ </ HtmlClassNameProvider >
103+ ) ;
104+ }
0 commit comments