Git Product home page Git Product logo

gatsby-source-rss-feed's Introduction

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
  }
}

gatsby-source-rss-feed's People

Contributors

boilemmashem avatar dependabot[bot] avatar matiasfha avatar mottox2 avatar ryanfiller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gatsby-source-rss-feed's Issues

Error: self signed certificate in certificate chain

I have added the certificate in the NPM config file and the issue is still occurring.

"gatsby-source-rss-feed" threw an error while running the sourceNodes lifecycle:

self signed certificate in certificate chain

Error: self signed certificate in certificate chain

  • node:_tls_wrap:1530 TLSSocket.onConnectSecure
    node:_tls_wrap:1530:34

  • node:events:390 TLSSocket.emit
    node:events:390:28

  • node:_tls_wrap:944 TLSSocket._finishInit
    node:_tls_wrap:944:8

  • node:_tls_wrap:725 TLSWrap.ssl.onhandshakedone
    node:_tls_wrap:725:12

not finished source and transform nodes - 1.118s

This is the NPM config file:

registry=http://registry.npmjs.org/
@bit:registry=https://node.bit.dev
//node.bitsrc.io/:_authToken=***
//node.bit.dev/:_authToken=***
//registry.npmjs.org/:_authToken=***
cafile=/Users/username/Documents/certs/cert.pem
NODE_TLS_REJECT_UNAUTHORIZED=0

Query fails when rss feed has no items.

Im trying to post job feeds. But I want to make we capture when there are no jobs to show a message, but the build fails because the name of the feed doesnt have items in the rss feed to add to the database.

plugin fails on sample run

when running plugin example (gatsby develope) from the documentation the following error occurs

`error Plugin gatsby-source-rss-feed returned an error
⠁ source and transform nodes

TypeError: Cannot destructure property createNode of 'undefined' or 'null'.

  • gatsby-node.js:20 Object.exports.sourceNodes
    [gatsby-movie]/[gatsby-source-rss-feed]/gatsby-node.js:20:7
    source and transform nodes

  • api-runner-node.js:110 runAPI
    [gatsby-movie]/[gatsby]/dist/utils/api-runner-node.js:110:36

  • api-runner-node.js:187 s
    [gatsby-movie]/[gatsby]/dist/utils/api-runner-node.js:187:33
    source and transform nodes

  • map.js:27
    [gatsby-movie]/[gatsby]/[async]/internal/map.js:27:9

  • eachOfLimit.js:64 replenish
    [gatsby-movie]/[gatsby]/[async]/internal/eachOfLimit.js:64:17
    source and transform nodes

  • eachOfLimit.js:49 iterateeCallback
    [gatsby-movie]/[gatsby]/[async]/internal/eachOfLimit.js:49:17

  • onlyOnce.js:12 orm nodes
    ⠂ source and transform nodes
    source and transform nodes

  • map.js:29
    ⠐ source and transform nodes

  • util.js:16 tryCatcherdes
    ⠂ source and transform nodes
    source and transform nodes

  • nodeify.js:23 Promise.successAdapter
    ⠈ source and transform nodes

  • promise.js:566 Promise._settlePromise
    [gatsby-movie]/[bluebird]/js/release/promise.js:566:21
    source and transform nodes

  • promise.js:606 Promise._settlePromiseCtx
    ⠐ source and transform nodes

  • async.js:138 Async._drainQueue
    ⠠ source and transform nodes
    source and transform nodes

  • async.js:143 Async._drainQueues
    [gatsby-movie]/[bluebird]/js/release/async.js:143:10

  • async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    ⢀ source and transform nodes
    source and transform nodes

⡀ source and transform nodes
⠄ source and transform nodes

⡀ source and transform nodes

⢀ source and transform nodes
⢀ source and transform nodes
⠠ source and transform nodes

⠐ source and transform nodes

⠈ source and transform nodes

⠁ source and transform nodes

⠂ source and transform nodes

⠄ source and transform nodes

⡀ source and transform nodes

⢀ source and transform nodes

⠠ source and transform nodes
⡀ source and transform nodes

⠈ source and transform nodes

⠁ source and transform nodes

⠂ source and transform nodes

⠄ source and transform nodes

⡀ source and transform nodes

⢀ source and transform nodes

⠠ source and transform nodes

⠐ source and transform nodes

⠈ source and transform nodes

⠁ source and transform nodes

⠂ source and transform nodes

⠄ source and transform nodes

⡀ source and transform nodes
`

Expected:
site starts

os:
windows 10

How to query multiple feeds?

Hi,

Thank you for the plugin. Working very well. I'm quite new with GraphQL. How would I configure the plugin to be able to query multiple feeds? Let's say I would have a local JSON file as following:

{
	"sport": [{
			"name": "sport 1",
			"url": "https://sportfeed1.com/rss.xml"
		},
		{
			"name": "sport 2",
			"url": "https://sportfeed2.com/rss.xml"
		}
	],
	"news": [{
			"name": "news 1",
			"url": "https://newsfeed1.com/rss.xml"
		},
		{
			"name": "news 2 2",
			"url": "https://newsfeed2.com/rss.xml"
		}
	]
}

Support RSS-parser 3.7.4

Recently, RSS-Parser added a fix to support custom fields at the top level of RSS feeds instead of nested within items -> rbren/rss-parser#94

I tried patching gatsby-node.js to get it properly picked up by GraphQL but my experience with Gatsby's internals is way too limited. I can confirm that the following setup retrieves the RSS feed correctly. I'd imagine that this would result in a StandingHS1.ranking object that, in this case, would house the array.

{
      resolve: `gatsby-source-rss-feed`,
      options: {
        url: `https://api.nevobo.nl/export/poule/regio-west/HPC/stand.rss`, //Stand HS1
        name: `StandingHS1`,
        parserOption: {
          customFields: {
            feed: [
              ["stand:ranking", "ranking", {keepArray: true}],
            ],
          }
        }
      }
    },

How to add namespaced elements to query?

I am having trouble figuring out how I can add namespaced elements to my GraphQL query.

For example, when trying to get: <itunes:duration>14:53</itunes:duration>

query {
    allFeedLibSynRss {
      edges {
        node {
          itunes:duration
        }
      }
    }
  }

I get the following error:
error Cannot query field "duration" on type "FeedLibSynRss" graphql/template-strings

Any idea how I can access namespaced elements?

Query error when adding custom XML field

Getting error GraphQL Error Unknown field youTubeUrl on type FeedLibSynRss after adding a custom field to the RSS XML.

query:

export const pageQuery = graphql`
  query {
    allFeedLibSynRss {
      edges {
        node {
          title
          youTubeUrl
          enclosure {
            url
          }
          itunes {
            season
            episode
            summary
            keywords
            duration
          }
        }
      }
    }
  }

snippet of RSS feed:

<item>
    ...
    <itunes:season>1</itunes:season>
    <itunes:episode>1</itunes:episode>
    <itunes:episodeType>full</itunes:episodeType>
    <!-- START ITEM EXTRA TAGS -->
    <youTubeUrl>https://www.youtube.com/watch?v=YE7VzlLtp-4</youTubeUrl>
    <!-- CLOSE ITEM EXTRA TAGS -->
</item>

Are the comments causing the issue? Unfortunately I don't have any control over them.

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.