feat(v2): enhance @docusaurus/plugin-content-blog (#1311)

* feat(v2): @docusaurus/plugin-content-blog

* address code review
This commit is contained in:
Endilie Yacop Sucipto 2019-03-26 01:39:58 +07:00 committed by GitHub
parent bd0cdbc701
commit 4bd5d3937e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 156 additions and 55 deletions

View file

@ -0,0 +1,45 @@
/**
* 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';
function BlogPage(props) {
const context = useContext(DocusaurusContext);
const {language, siteConfig = {}} = context;
const {baseUrl, favicon} = siteConfig;
const {
metadata: {posts = []},
modules: BlogPosts,
} = props;
return (
<Layout>
<Head>
<title>Blog</title>
{favicon && <link rel="shortcut icon" href={baseUrl + favicon} />}
{language && <html lang={language} />}
{language && <meta name="docsearch:language" content={language} />}
</Head>
<div>
{BlogPosts.map((PostContent, index) => (
<Post
key={index}
truncated={posts[index].truncatedSource}
metadata={posts[index]}>
<PostContent />
</Post>
))}
</div>
</Layout>
);
}
export default BlogPage;