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:
Ólafur Páll Geirsson 2019-06-15 18:24:15 +02:00 committed by Yangshun Tay
parent 60f9228d67
commit da3c91373e
4 changed files with 30 additions and 19 deletions

View file

@ -28,6 +28,7 @@ module.exports = function(type) {
readMetadata.generateMetadataBlog(siteConfig);
const MetadataBlog = require('../core/MetadataBlog.js');
const MetadataPublicBlog = MetadataBlog.filter(item => !item.draft);
const feed = new Feed({
title: `${siteConfig.title} Blog`,
@ -38,10 +39,10 @@ module.exports = function(type) {
link: blogRootURL,
image: siteImageURL,
copyright: siteConfig.copyright,
updated: new Date(MetadataBlog[0].date),
updated: new Date(MetadataPublicBlog[0].date),
});
MetadataBlog.forEach(post => {
MetadataPublicBlog.forEach(post => {
const url = `${blogRootURL}/${post.path}`;
const description = utils.blogPostHasTruncateMarker(post.content)
? renderMarkdown(utils.extractBlogPostBeforeTruncate(post.content))