generateFeed = function generateFeed(baseUrl, data) {
    const feed = new RSS({
        title: data.title,
        description: data.description,
        generator: 'Ghost ' + data.safeVersion,
        feed_url: urlUtils.urlFor({relativeUrl: baseUrl}, true),
        site_url: urlUtils.urlFor('home', true),
        image_url: urlUtils.urlFor({relativeUrl: 'favicon.png'}, true),
        ttl: '60',
        custom_namespaces: {
            content: 'http://purl.org/rss/1.0/modules/content/',
            media: 'http://search.yahoo.com/mrss/'
        }
    });

    return data.posts.reduce((feedPromise, post) => {
        return feedPromise.then(() => {
            const item = generateItem(post);
            return feed.item(item);
        });
    }, Promise.resolve()).then(() => {
        return feed.xml();
    });
}
Generate Feed

Data is an object which contains the res.locals + results from fetching a collection, but without related data.

@param {string} baseUrl
@param {{title, description, safeVersion, posts}} data