GithubHelp home page GithubHelp logo

gridsome-plugin-feed's Introduction

gridsome-plugin-feed

Generate an RSS, Atom, and/or JSON feed for your Gridsome site.

Install

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

Example

module.exports = {
  plugins: [
    {
      use: 'gridsome-plugin-feed',
      options: {
        // Required: array of `GraphQL` type names you wish to include
        contentTypes: ['BlogPost', 'NewsPost'],
        // Optional: any properties you wish to set for `Feed()` constructor
        // See https://www.npmjs.com/package/feed#example for available properties
        feedOptions: {
          title: 'My Awesome Blog Feed',
          description: 'Best blog feed evah.'
        },
        // === All options after this point show their default values ===
        // Optional; opt into which feeds you wish to generate, and set their output path
        rss: {
          enabled: true,
          output: '/feed.xml'
        },
        atom: {
          enabled: false,
          output: '/feed.atom'
        },
        json: {
          enabled: false,
          output: '/feed.json'
        },
        // Optional: the maximum number of items to include in your feed
        maxItems: 25,
        // Optional: an array of properties passed to `Feed.addItem()` that will be parsed for
        // URLs in HTML (ensures that URLs are full `http` URLs rather than site-relative).
        // To disable this functionality, set to `null`.
        htmlFields: ['description', 'content'],
        // Optional: if you wish to enforce trailing slashes for site URLs
        enforceTrailingSlashes: false,
        // Optional: a method that accepts a node and returns true (include) or false (exclude)
        // Example: only past-dated nodes: `filterNodes: (node) => node.date <= new Date()`
        filterNodes: (node) => true,
        // Optional: a method that accepts a node and returns an object for `Feed.addItem()`
        // See https://www.npmjs.com/package/feed#example for available properties
        // NOTE: `date` field MUST be a Javascript `Date` object
        nodeToFeedItem: (node) => ({
          title: node.title,
          date: node.date || node.fields.date,
          content: node.content
        })
      }
    }
  ]
}

gridsome-plugin-feed's People

Contributors

onecrayon avatar

Stargazers

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

Watchers

 avatar  avatar

gridsome-plugin-feed's Issues

Feed Output Not Transformed

I've been trying to implement this plugin for a simple blog using the @gridsome/source-filesystem plugin and the remark transformer. The plugin generates feeds perfectly, but the content of each feed item is raw Markdown text and not the transformed HTML text I was expecting.

Poking around, it looks like the collection returned from api.store.getContentType holds each items "un-transformed" content data. Do you know if there is there another way to see the same data after it has been transformed using the same afterBuild hook?

Below is how I have the plugin configured in my config file:

[{
    use: 'gridsome-plugin-feed',
    options: {
      contentTypes: ['BlogPost'],
      feedOptions: {
        title: 'Six Impossible Things',
        description: 'Musings and ramblings'
      },
      rss: {
        enabled: true,
        output: '/feed.xml'
      },
      atom: {
        enabled: true,
        output: '/feed.atom'
      },
      json: {
        enabled: true,
        output: '/feed.json'
      },
      nodeToFeedItem: node => ({
        title: node.title,
        description: node.description,
        date: new Date(node.date),
        content: node.content,
        author: 'Tonio Hubilla',
        url: 'https://ton-hub.net/' + node.path
      })
    }
}]

I'm running version 1.0.2 of the plugin with version 0.6.9 of gridsome.

Failed to load resource error

I get this error sometimes:

/assets/data/rss.xml/index.json:1 Failed to load resource: the server responded with a status of 404 ()

It looks like there is JavaScript code trying to add the rss.xml file as a prefetch link:

image

TypeError: entry.date.toUTCString is not a function

When I run gridsome develop I get the following error:

enerate RSS feed at /feed.xml
TypeError: entry.date.toUTCString is not a function
    at /Users/rasulkireev/git/webdev/gridsome-personal-webite/node_modules/feed/lib/rss2.js:86:48
    at Array.map (<anonymous>)
    at Object.default (/Users/rasulkireev/git/webdev/gridsome-personal-webite/node_modules/feed/lib/rss2.js:68:15)
    at Feed.rss2 (/Users/rasulkireev/git/webdev/gridsome-personal-webite/node_modules/feed/lib/feed.js:18:56)
    at /Users/rasulkireev/git/webdev/gridsome-personal-webite/node_modules/gridsome-plugin-feed/index.js:104:60
    at Plugins.run (/Users/rasulkireev/git/webdev/gridsome-personal-webite/node_modules/gridsome/lib/app/Plugins.js:141:17)
    at async module.exports (/Users/rasulkireev/git/webdev/gridsome-personal-webite/node_modules/gridsome/lib/build.js:41:3)

This is how my gridsome.config.js looks like:

{
      use: 'gridsome-plugin-feed',
      options: {
        contentTypes: ['Post'],
        feedOptions: {
          title: 'Rasul Kireev | Blog Feed',
          description: 'All posts written by Rasul Kireev'
        },
        rss: {
          enabled: true,
          output: '/feed.xml'
        },
        atom: {
          enabled: true,
          output: '/feed.atom'
        },
        json: {
          enabled: true,
          output: '/feed.json'
        },
    }
},

Do you have ideas why this error occurs? Thanks in advance.

TypeError: ERR_INVALID_URL

I started getting this error recently:

Generate RSS feed at /rss.xml
TypeError [ERR_INVALID_URL]: Invalid URL: /images/hero/NuGet-1366x768.png
    at onParseError (internal/url.js:257:9)
    at new URL (internal/url.js:333:5)
    at formatEnclosure (C:\GitHub\rehansaeed.github.io\node_modules\feed\lib\rss2.js:153:22)
    at C:\GitHub\rehansaeed.github.io\node_modules\feed\lib\rss2.js:131:30
    at Array.map (<anonymous>)
    at Object.default (C:\GitHub\rehansaeed.github.io\node_modules\feed\lib\rss2.js:83:15)
    at Feed.rss2 (C:\GitHub\rehansaeed.github.io\node_modules\feed\lib\feed.js:19:56)
    at C:\GitHub\rehansaeed.github.io\node_modules\gridsome-plugin-feed\index.js:104:60
    at Plugins.run (C:\GitHub\rehansaeed.github.io\node_modules\gridsome\lib\app\Plugins.js:141:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async module.exports (C:\GitHub\rehansaeed.github.io\node_modules\gridsome\lib\build.js:42:3)

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.