mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
feat: add "unlisted" front matter option for blog posts (#1396)
* Add `unlisted` header option for blog posts, fixes #1393. Previously, the blog sidebar listed the most recent blog posts sorted by their publish date. This commit adds the ability to hide a specific blog post from the sidebar and the feed of all blog posts by adding the `unlisted: true` header option. ```md title: My Draft Post unlisted: true # Hide from blog sidebar and main blog page feed. --- ``` * Rename "unlisted" into "draft".
This commit is contained in:
parent
60f9228d67
commit
da3c91373e
4 changed files with 30 additions and 19 deletions
|
@ -10,6 +10,8 @@ const SideNav = require('./nav/SideNav.js');
|
|||
|
||||
const MetadataBlog = require('./MetadataBlog.js');
|
||||
|
||||
const MetadataPublicBlog = MetadataBlog.filter(item => !item.draft);
|
||||
|
||||
class BlogSidebar extends React.Component {
|
||||
render() {
|
||||
let blogSidebarCount = 5;
|
||||
|
@ -17,7 +19,7 @@ class BlogSidebar extends React.Component {
|
|||
let blogSidebarTitle = blogSidebarTitleConfig.default || 'Recent Posts';
|
||||
if (this.props.config.blogSidebarCount) {
|
||||
if (this.props.config.blogSidebarCount === 'ALL') {
|
||||
blogSidebarCount = MetadataBlog.length;
|
||||
blogSidebarCount = MetadataPublicBlog.length;
|
||||
blogSidebarTitle = blogSidebarTitleConfig.all || 'All Blog Posts';
|
||||
} else {
|
||||
blogSidebarCount = this.props.config.blogSidebarCount;
|
||||
|
@ -28,7 +30,7 @@ class BlogSidebar extends React.Component {
|
|||
{
|
||||
type: 'CATEGORY',
|
||||
title: blogSidebarTitle,
|
||||
children: MetadataBlog.slice(0, blogSidebarCount).map(item => ({
|
||||
children: MetadataPublicBlog.slice(0, blogSidebarCount).map(item => ({
|
||||
type: 'LINK',
|
||||
item,
|
||||
})),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue