
Yet another metalsmith plugin to generate an RSS feeds.
Compatible with (but does not depend on):
Installation
$ npm install metalsmith-rssfeed --save
Usage
var rssfeed = require('metalsmith-rssfeed');
metalsmith.use(reefeed({
collection: "posts",
limit: 20,
name: "feed.xml",
});
Examples
create a rss feed for containing every post with a specific tag and save it in one file per tag:
metalsmith.use(reefeed({
collectionKey: "tags",
name: ":collection.xml",
});
create a rss feed for containing every post with a specific tag and save it in one file per tag:
metalsmith.use(reefeed({
collectionKey: "tags",
name: ":collection.xml",
});
merge all tagged posts in a single feed alltags.xml:
metalsmith.use(reefeed({
title: 'Tagged Posts'
description: 'All tagged posts are in this feed.'
collectionKey: "tags",
name: "alltags.xml",
});
Options and default values
{
name: ':collection.xml',
author: '',
title: '',
description: '',
siteUrl: '',
generator: 'metalsmith-rssfeed',
feedOptions: (CollectionName, collection, options) => ({
generator: options.generator,
site_url: options.siteUrl,
author: options.author.name || options.author,
description: options.description.replace(o.replaceToken, c),
title: options.title.replace(o.replaceToken, c),
feed_url: options.pathToUrl(feedName)
}),
collection: false,
collectionKey: o.collection ? 'collections' : false,
replaceToken: ':collection',
pattern: '**';
permalinkKey: 'permalink';
o.limit: false;
pathToUrl: p => url.resolve(options.siteUrl, p);
itemOptions: (file, options) => ({
title: file.title,
description: file.less || file.excerpt || file.contents,
author: file.author.name || file.author,
url: options.pathToUrl(file[options.permalinkKey] || file.path, options),
date: file.date,
guid: file[options.permalinkKey] ? null : file.path
})
Notes
metalsmith-feed is another great feed creation plugin, however it strictly depends on collections.