A Gridsome plugin to generate RSS, Atom and JSON feeds
yarn add @microflash/gridsome-plugin-feed
npm install @microflash/gridsome-plugin-feed
// gridsome.config.js
module.exports = {
plugins: [
{
use: '@microflash/gridsome-plugin-feed',
options: {
// (required) Provide GraphQL collection types
contentTypes: ['BlogPost'],
// (optional) Properties used by feed API
// See https://github.com/jpmonette/feed#example for all options
feedOptions: {
title: 'My blog',
description: 'My Personal blog on books, cookies and kittens'
},
// Available options with their default values
// (optional) Options for feed formats
// RSS is enabled by default
rss: {
enabled: true,
output: '/feed.xml'
},
atom: {
enabled: false,
output: '/feed.atom'
},
json: {
enabled: false,
output: '/feed.json'
},
// (optional) number of items to include in a feed
maxItems: 25,
// (optional) an array of properties to be parsed as HTML
// Converts relative URLs to absolute URLs
// You can disable this by omitting the option
htmlFields: ['content'],
// (optional) appends a trailing slash to the URLs
enforceTrailingSlashes: false,
// (optional) a function to filter out the nodes
// e.g., filter out all outdated posts, filterNodes: (node) => !!node.outdated
filterNodes: (node) => true,
// (optional) sets the properties on each feed item
// See https://github.com/jpmonette/feed#example for all options
nodeToFeedItem: (node) => ({
title: node.title,
date: node.date,
content: node.content
})
}
}
]
}
Feel free to contribute to the project. Take a look at the contribution guidelines to get started.
@onecrayon for implementing the original plugin