Skip to content

Commit

Permalink
feat: create rss feed
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosirera committed Aug 4, 2020
1 parent 50bff3b commit b4a4886
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 2 deletions.
35 changes: 35 additions & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default {
'@nuxtjs/pwa',
// Doc: https://github.com/nuxt/content
'@nuxt/content',
'@nuxtjs/feed',
'nuxt-i18n',
'@nuxtjs/color-mode',
'@nuxtjs/svg',
Expand Down Expand Up @@ -83,6 +84,40 @@ export default {
},
},
},
/*
**
*/
feed: [
{
path: '/feed.xml',
type: 'rss2',
async create(feed) {
const baseUrlArticles = 'https://pablosirera.com/blog'
const { $content } = require('@nuxt/content')

feed.options = {
title: `Blog | ${process.env.APP_TITLE}`,
description: process.env.APP_DESC,
link: baseUrlArticles,
}
const articles = await $content('blog').fetch()

articles.forEach((article) => {
const url = `${baseUrlArticles}/${article.slug}`

feed.addItem({
title: article.title,
id: url,
link: url,
date: new Date(article.date),
description: article.description,
content: article.summary,
author: 'Pablo Sirera',
})
})
},
},
],
/*
** env variables
*/
Expand Down
52 changes: 51 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@miyaoka/vue-youtube-embed-lite": "^1.1.0",
"@nuxt/components": "^1.0.6",
"@nuxt/content": "^1.4.1",
"@nuxtjs/feed": "^2.0.0",
"@nuxtjs/pwa": "^3.0.0-beta.20",
"nuxt": "^2.13.0",
"nuxt-fontawesome": "^0.4.0",
Expand Down Expand Up @@ -54,4 +55,4 @@
"stylelint-config-prettier": "^8.0.1",
"stylelint-config-standard": "^20.0.0"
}
}
}

0 comments on commit b4a4886

Please sign in to comment.