Nefarious Pomegranate Magnate

    eleventy-rss-helper
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.1 • Public • Published

    eleventy-rss-helper

    Create RSS 2.0 feeds for an Eleventy site.

    This is a wrapper around the rss module.

    Install

    npm install eleventy-rss-helper

    Usage

    1. Create feed file

    Create a feed file (e.g. feed.11ty.js) in a directory that Eleventy will process.

    Paste this boilerplate into the file:

    const createRssFeed = require('eleventy-rss-helper');
     
    module.exports = createRssFeed({
      permalink: '/feed.xml',
      feedOptions(data) {
        return {
     
        };
      },
      items(collections, data) {
     
      },
      itemOptions(item, data) {
        return {
     
        };
      }
    });

    2. Fill in the empty functions

    feedOptions(data)

    Receives

    • Eleventy data object

    Returns object to be used as feedOptions with the rss module.

    items(collections, data)

    Receives

    Returns array of items to include in the feed.

    itemOptions(item, data)

    Invoked once for each element in array returned by items().

    Receives

    • An item from the array returned by your items() function
    • Eleventy data object

    Returns object to be used as itemOptions with the rss module.

    Example

    const createRssFeed = require('eleventy-rss-helper');
     
    const permalink = '/feed.xml';
    const baseUrl = 'https://mysite.com';
     
    module.exports = createRssFeed({
      permalink,
      feedOptions(data) {
        return {
          title: 'mysite.com',
          description: 'Latest posts from mysite.com',
          feed_url: `${baseUrl}${permalink}`,
          site_url: baseUrl
        };
      },
      items(collections, data) {
        // last 20 posts, newest first
        return collections.post
          .slice(-20)
          .reverse();
      },
      itemOptions(item, data) {
        return {
          title: item.data.title,
          description: '...',
          url: `${baseUrl}${item.url}`,
          date: item.date
        };
      }
    });
     

    License

    MIT

    Install

    npm i eleventy-rss-helper

    DownloadsWeekly Downloads

    4

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    22.8 kB

    Total Files

    8

    Last publish

    Collaborators

    • psalaets