Giter VIP home page Giter VIP logo

gridsome-plugin-rss's Introduction

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: './static',
          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.

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: ./static
    • name: rss.xml

Specify the output directory and filename of the generated RSS.

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: './static/',
  name: 'rss' // or rss.xml
}

gridsome-plugin-rss's People

Contributors

darthmeme avatar mynar7 avatar robaxelsen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.