Skip to content

Commit

Permalink
remove guid field in feed.xml and add posts.published generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Sutan Gading Fadhillah Nasution committed Aug 30, 2019
1 parent 9c392a4 commit 25e34a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -95,3 +95,4 @@ OneSignalSDK*

# auto generated files
/contents/posts/published/index.js
/static/posts.published.json
9 changes: 6 additions & 3 deletions generate.js
Expand Up @@ -16,13 +16,16 @@ const generatePostList = async () => {
const name = Object.keys(res)[0]
return fs.readFile(path.resolve(publishedPath, name, 'index.md'), 'utf-8')
.then(res => fmparse(res))
.then(({ attributes }) => ({ name, date: attributes.date }))
.then(({ attributes }) => attributes)
}))

result = result.sort((a, b) => (a.date.getTime() < b.date.getTime()) ? 1 : -1)
result = `/* eslint-disable */\n\nexport default ${JSON.stringify(result)}`

fs.writeFile(path.resolve(publishedPath, 'index.js'), result)
const generatedList = result.map(attr => ({ name: attr.slug }))

fs.writeFile(path.resolve(publishedPath, 'index.js'), `/* eslint-disable */\n\nexport default ${JSON.stringify(generatedList)}`)
fs.writeFile(path.resolve(__dirname, 'static/posts.published.json'), JSON.stringify(result))

console.log('Done generate published post lists\n')
}

Expand Down
1 change: 0 additions & 1 deletion nuxt.config.js
Expand Up @@ -143,7 +143,6 @@ export default {
.then(content => {
feed.addItem({
title: content.title,
guid: `${content.slug}_${new Date(content.date).getTime()}`,
link: `${env.productionUrl}/blog/${content.slug}`,
description: content.description,
content: content.html
Expand Down

0 comments on commit 25e34a3

Please sign in to comment.