metalsmith-feed
A metalsmith plugin to generate an RSS feed for a collection.
Just a thin wrapper around the rss module.
Requires metalsmith-collections. Plays nicely with permalinks, more, and excerpts.
Usage
const collections = ;const feed = ; ;
Options
Take a look at the tests for example usage.
-
collection
string Required. The name of the configured metalsmith-collection to feed. -
limit
Number Optional. Maximum number of documents to show in the feed. Defaults to20
. Set tofalse
to include all documents. -
destination
string Optional. File path to write the rendered XML feed. Defaults to'rss.xml'
. -
preprocess
function Optional. Map collection entries to RSS items. Some fields (likedescription
andurl
) have default mappings that support Metalsmith plugin conventions. Many other fields (liketitle
,author
, anddate
) work great without any customization. You can customize any of these fields inpreprocess
.
url: ...
If files have path
metadata (perhaps from metalsmith-permalinks)
but not url
metadata, we'll prefix path
with site_url
to
generate links.
*/
})
})
);
Remaining options are passed to the [rss](https://github.com/dylang/node-rss) module as `feedOptions`, along with `metadata.site`.
### Multiple Feeds
Have a few collections you'd like to export? Register this plugin once for each:
```js
Metalsmith('example')
.use(
collections({
foo: 'foo/*.html',
bar: 'bar/*.html'
})
)
.use(
feed({
collection: 'foo',
destination: 'foo-rss.xml'
})
)
.use(
feed({
collection: 'bar',
destination: 'bar-rss.xml'
})
);