Skip to content

Latest commit

 

History

History
130 lines (106 loc) · 2.18 KB

README.md

File metadata and controls

130 lines (106 loc) · 2.18 KB

gatsby-source-rss-feed

npm version

Source plugin for pulling data into Gatsby from RSS feed.

Install

npm install --save gatsby-source-rss-feed

or

yarn add gatsby-source-rss-feed

How to use

basic pattern

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-rss-feed`,
      options: {
        url: `http://static.userland.com/gems/backend/rssTwoExample2.xml`,
        name: `ExampleRSS`,
      }
    }
  ]
}

use multiple feed

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-rss-feed`,
      options: {
        url: `http://static.userland.com/gems/backend/rssTwoExample2.xml`,
        name: `ExampleRSS`,
      }
    }
    {
      resolve: `gatsby-source-rss-feed`,
      options: {
        url: `http://static.userland.com/gems/backend/rssTwoExample2.xml`,
        name: `MyBlog`,
      }
    }
  ]
}

with parserOption

This library use rss-parser.

You can pass options via parserOptions.

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-rss-feed`,
      options: {
        url: `http://static.userland.com/gems/backend/rssTwoExample2.xml`,
        name: `ExampleRSS`,
        // Optional
        // Read parser document: https://github.com/bobby-brennan/rss-parser#readme
        parserOption: {
          customFields: {
            item: ['itunes:duration']
          }
        }
      }
    }
  ]
}

How to query

Query is Feed${name}.

When name of options is ExampleRSS, query named as FeedExampleRSS.

{
  allFeedExampleRSS {
    edges {
      node {
        title
        link
        content
      }
    }
  }

  feedExampleRSS {
    title
    link
    content
  }
}

Data not part of the items can be accessed with Feed${name}Meta

When name of options is ExampleRSS, query named as FeedExampleRSSMeta.

{
  feedExampleRSSMeta {
    title
    author
    description
    lastBuiltDate
  }
}