eleventy-plugin-rss icon indicating copy to clipboard operation
eleventy-plugin-rss copied to clipboard

Support multiple feeds + fix permalink bug

Open robb-j opened this issue 1 year ago • 3 comments

Hey, I was wondering how hard it would be to support generating multiple feeds using the newer feedPlugin rather than having to manually create each feed template. I also found a bug that is fixed here but doesn't have to be tied to this.

Multiple feeds

My thinking is that you would pass feeds in your options which is an array of the previous "options" objects and it would add a virtual template for each. So you could have multiple types of feed or feeds for different content types.

This wasn't too hard to achieve but does change how it works internally a touch, the current plugin is split between eleventyFeedPlugin and the new addTemplate where that adds a single virtual template for a feed and the plugin does the things that should only happen once.

the bug

In exploring this I found the feed plugin crashes if you have an item with permalink set to false, which I'd been using to turn-off pages without deleting them. Is this still a recommended thing to do? My solution was to add a namespaced filter eleventyFeedActive to each of the feed types that filters out any collection items that have a falsey url.

testing

For my garden project I was using my local version of the plugin with this setup:

I added a test for it too

export default function (eleventyConfig) {
  eleventyConfig.addPlugin(feedPlugin, {
    feeds: [
      {
        type: 'json',
        outputPath: '/films.json',
        collection: { name: 'film', limit: 0 },
        metadata: {
          language: 'en',
          title: "Rob's Films",
          subtitle: "The films I've watched recently",
          base: 'https://garden.r0b.tech/',
          author: { name: 'Rob Anderson' },
        },
      },
      {
        type: 'json',
        outputPath: '/photos.json',
        collection: { name: 'photo', limit: 0 },
        metadata: {
          language: 'en',
          title: "Rob's Pics",
          subtitle: "Nice pictures I've take for you",
          base: 'https://garden.r0b.tech/',
          author: { name: 'Rob Anderson' },
        },
      },
      {
        type: 'json',
        outputPath: '/notes.json',
        collection: { name: 'note', limit: 0 },
        metadata: {
          language: 'en',
          title: "Rob's Notes",
          subtitle: "Thoughts I've had that might be interesting",
          base: 'https://garden.r0b.tech/',
          author: { name: 'Rob Anderson' },
        },
      },
    ]
  })
}

robb-j avatar Nov 02 '24 20:11 robb-j