mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-24 03:58:49 +02:00
feat(v2): enhance @docusaurus/plugin-content-blog (#1311)
* feat(v2): @docusaurus/plugin-content-blog * address code review
This commit is contained in:
parent
bd0cdbc701
commit
4bd5d3937e
11 changed files with 156 additions and 55 deletions
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import React, {useContext} from 'react';
|
||||
import Head from '@docusaurus/Head';
|
||||
import Layout from '@theme/Layout'; // eslint-disable-line
|
||||
|
||||
import DocusaurusContext from '@docusaurus/context';
|
||||
import Post from '../Post';
|
||||
import styles from './styles.module.css';
|
||||
|
||||
function BlogPost(props) {
|
||||
const {metadata: contextMetadata = {}, siteConfig = {}} = useContext(
|
||||
DocusaurusContext,
|
||||
);
|
||||
const {baseUrl, favicon} = siteConfig;
|
||||
const {language, title} = contextMetadata;
|
||||
const {modules, metadata} = props;
|
||||
const BlogPostContents = modules[0];
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<Head defaultTitle={siteConfig.title}>
|
||||
{title && <title>{title}</title>}
|
||||
{favicon && <link rel="shortcut icon" href={baseUrl + favicon} />}
|
||||
{language && <html lang={language} />}
|
||||
</Head>
|
||||
{BlogPostContents && (
|
||||
<div className={styles.blogPostContainer}>
|
||||
<Post metadata={metadata}>
|
||||
<BlogPostContents />
|
||||
</Post>
|
||||
</div>
|
||||
)}
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export default BlogPost;
|
Loading…
Add table
Add a link
Reference in a new issue