Add published flag to posts
This commit is contained in:
parent
54ed7c8f87
commit
c638fb1ca3
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: blog
|
layout: blog
|
||||||
title: dev - Ide to ? copy
|
title: dev - Ide to ? copy
|
||||||
|
published: true
|
||||||
date: 2020-01-09T17:24:13.481Z
|
date: 2020-01-09T17:24:13.481Z
|
||||||
thumbnail: /images/uploads/screenshot.gif
|
thumbnail: /images/uploads/screenshot.gif
|
||||||
rating: 4
|
rating: 4
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: blog
|
layout: blog
|
||||||
title: dev - Ide to ?
|
title: dev - Ide to ?
|
||||||
|
published: true
|
||||||
date: 2019-08-09T17:24:13.481Z
|
date: 2019-08-09T17:24:13.481Z
|
||||||
thumbnail: /images/uploads/screenshot.gif
|
thumbnail: /images/uploads/screenshot.gif
|
||||||
tags:
|
tags:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: blog
|
layout: blog
|
||||||
title: dev - Anothert one
|
title: dev - Anothert one
|
||||||
|
published: true
|
||||||
date: 2019-11-03T11:01:32.621Z
|
date: 2019-11-03T11:01:32.621Z
|
||||||
thumbnail: /images/uploads/responzio.png
|
thumbnail: /images/uploads/responzio.png
|
||||||
rating: 2
|
rating: 2
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { readdir, readFile } from 'fs'
|
import { readdir, readFile } from 'fs'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import { basename } from 'path'
|
import { basename } from 'path'
|
||||||
import { pipe, partial, prop, sortBy, reverse } from 'ramda'
|
import { pipe, partial, prop, sortBy, reverse, filter } from 'ramda'
|
||||||
import fm from 'front-matter'
|
import fm from 'front-matter'
|
||||||
import marked from 'marked'
|
import marked from 'marked'
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ export async function get(req, res) {
|
|||||||
const filteredContents = pipe(
|
const filteredContents = pipe(
|
||||||
sortBy(prop('date')),
|
sortBy(prop('date')),
|
||||||
reverse,
|
reverse,
|
||||||
|
filter(article => article.published),
|
||||||
partial(filterByTag, [tag])
|
partial(filterByTag, [tag])
|
||||||
)(contents)
|
)(contents)
|
||||||
|
|
||||||
@ -55,3 +56,7 @@ function filterDevelopmentFiles(files) {
|
|||||||
function filterByTag(tag, contents) {
|
function filterByTag(tag, contents) {
|
||||||
return tag ? contents.filter(content => content.tags.includes(tag)) : contents
|
return tag ? contents.filter(content => content.tags.includes(tag)) : contents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterPublished(article) {
|
||||||
|
return article.published
|
||||||
|
}
|
||||||
|
@ -15,6 +15,12 @@ collections:
|
|||||||
fields: # The fields for each document, usually in front matter
|
fields: # The fields for each document, usually in front matter
|
||||||
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'blog' }
|
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'blog' }
|
||||||
- { label: 'Title', name: 'title', widget: 'string' }
|
- { label: 'Title', name: 'title', widget: 'string' }
|
||||||
|
- {
|
||||||
|
label: 'Published',
|
||||||
|
name: 'published',
|
||||||
|
widget: 'boolean',
|
||||||
|
default: true,
|
||||||
|
}
|
||||||
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
|
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
|
||||||
- { label: 'Featured Image', name: 'thumbnail', widget: 'image' }
|
- { label: 'Featured Image', name: 'thumbnail', widget: 'image' }
|
||||||
- {
|
- {
|
||||||
|
Loading…
Reference in New Issue
Block a user