npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gridsome-plugin-rss

v1.4.0

Published

Generate an RSS feed from your Gridsome data store

Downloads

193

Readme

gridsome-plugin-rss

Generate an RSS feed from your Gridsome data store

Install

  • yarn add gridsome-plugin-rss
  • npm install gridsome-plugin-rss

Usage

module.exports = {
  plugins: [
    {
      use: 'gridsome-plugin-rss',
      options: {
        contentTypeName: 'BlogPost',
        feedOptions: {
          title: 'My Awesome Blog',
          feed_url: 'https://superblog.com/rss.xml',
          site_url: 'https://superblog.com'
        },
        feedItemOptions: node => ({
          title: node.title,
          description: node.description,
          url: 'https://superblog.com/post/' + node.slug,
          author: node.fields.author
        }),
        output: {
          dir: './dist',
          name: 'rss.xml'
        }
      }
    }
  ]
}

Options

contentTypeName

  • Type: string required

The typeName of the contentType you wish to generate your RSS file for.

const products = store.addContentType({
  typeName: 'BlogPost', // <-- add this to contentTypename
  route: '/blog/:slug',
})

latest

  • Type: boolean optional

If true, sorts your RSS file with newest items at the top.

NOTE: In order to sort chronologically, all nodes passed to this plugin must have a valid date property. date must be a timestamp string or unix timestamp (integer). If all nodes do not have valid dates, RSS items will NOT be sorted. See JS Date Object Parameters on MDN for details.

dateField

  • Type: string optional
  • Default: 'date'

If set, it will sort your items chonologically by the date field you set.

filterItems

  • Type: Function optional
  • Arg node
  • Returns boolean

If set, it will filter your items using the function.

// In the options for gridsome-plugin-rss
filterItems: node => node.status === 'published'

maxItems

  • Type: number optional

Limits the amount of items included in your RSS feed.

NOTE: Should be used with latest set to true, otherwise newer items will be excluded.

feedOptions

  • Type object required

The top level options for your RSS feed. See dylang/node-rss#feedoptions for all options

feedItemOptions(node)

  • Type Function required
  • Arg node
  • Returns object

The item level options for your RSS feed. For each option (see dylang/node-rss#itemoptions for all options), node is the object that you passed into Collection.addNode

NOTE: Since Gridsome will convert any node field into camelCase, make sure that any property you access on node is also camelCased.

Example:

// In gridsome.server.js
BlogPost.addNode({
  title: BlogPost.title,
  description: BlogPost.description,
  fields: {
    AuthorName: BlogPost.AuthorName,
    'url-slug': BlogPost['url-slug']
  }
})

...

// In the options for gridsome-plugin-rss
feedItemOptions: node => ({
  title: node.title,
  description: node.description,
  url: 'https://superblog.com/post/' + node.fields.urlSlug,
  author: node.fields.authorName,
})

output

  • Type object optional
  • Defaults:
    • dir: ./dist
    • name: rss.xml

Specify the output directory and filename of the generated RSS. By default, it is your configured build output directory (the configured value for key outputDir) or just ./dist

dir - a relative path to desired output directory.

name - the filename of your XML file. You can omit the extension if you want to.

Example:

output: {
  dir: './dist/',
  name: 'rss' // or rss.xml
}