Git Product home page Git Product logo

gatsby-plugin-feed-generator's People

Contributors

markmichon avatar

Stargazers

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

Watchers

 avatar  avatar

gatsby-plugin-feed-generator's Issues

Write tests

This could really use some tests so a running Gatsby site doesn't need to be used as a sandbox.

Implement methods for non-markdown based feeds

Currently the plugin relies heavily on the use and structure of allMarkdownRemark and it's graphql structure. It would be ideal if this could be abstracted out into the config to allow for other formats, and in the future combining multiple formats into a single feed.

Add support for path prefix

Support should mirror gatsby's approach via pathPrefix in gatsby-config, however it looks like withPrefix will be deprecated in Gatsby v3, so allowing users to set custom prefixes for each feed to allow something like the following would be better: sitename.com/blog, sitename.com/photos, etc.

This can currently be achieved by prefixing the name of the feed in the config, so it may be better to document that instead of building out functionality before Gatsby makes changes.

Gatsby v2/regeneratorRuntime

Looks like there is an issue with expecting regeneratorRuntime/v2:

error Plugin gatsby-plugin-feed-generator returned an error


  ReferenceError: regeneratorRuntime is not defined

Missing feeds

I'm suddenly seeing the feeds and feed links not being generated on gatsby 2.15.20 / gatsby-plugin-feed-generator 2.0.3, but I'm also not seeing any errors. My config looks like this:

    {
      resolve: "gatsby-plugin-feed-generator",
      options: {
        siteQuery: `
          {
            site {
              siteMetadata {
                title
                description
                siteUrl
                author
              }
            }
          }
        `,
        feeds: [
          {
            name: 'feed',
            query: `
              {
                allMarkdownRemark(
                  filter: { frontmatter: { templateKey: { eq: "post" }, published: { eq: true } } },
                  sort: { order: DESC, fields: [frontmatter___date] }
                ) {
                  edges {
                    node {
                      html
                      id
                      frontmatter {
                        date
                        path
                        title
                      }
                    }
                  }
                }
              }
            `,
            normalize: ({ query: { site, allMarkdownRemark } }) => {
              return allMarkdownRemark.edges.map(edge => {
                return {
                  title: edge.node.frontmatter.title,
                  date: edge.node.frontmatter.date,
                  url: site.siteMetadata.siteUrl + edge.node.frontmatter.path,
                  html: edge.node.html,
                }
              })
            },
          }
        ],
      },
    },

`RangeError: Invalid time value` on build

Testing on a simple query with frontmatter fields title and slug.

Trying to build produced the following error:

error Plugin gatsby-plugin-feed-generator returned an error
  RangeError: Invalid time value
  - Date.toISOString
  - json.js:51 
    [gatsby-test]/[feed]/lib/json.js:51:48
  - Array.map
  - json.js:33 Object.exports.default
    [gatsby-test]/[feed]/lib/json.js:33:24
  - feed.js:19 Feed.json1
    [gatsby-test]/[feed]/lib/feed.js:19:57
  - gatsby-node.js:71 _loop$
    [gatsby-test]/[gatsby-plugin-feed-generator]/gatsby-node.js:71:117

`path.join` mangles schema-delimiting double-slash

In a couple places in gatsby-node this is employed:

path.join(siteUrl, slug),

If siteUrl is a fully qualified URL with a schema, such as https://www.example.org/, this has the undesirable effect of treating the schema-host separator as a path divider:

// output => https:/www.example.org/[slug]

There are some other “url join” libraries out there; I resolved by doing the following instead:

const url = {
  join: (...parts) => {
    let result = "" + parts.shift()
    parts.forEach(part => {
      const trailingSlashPresent = result.charAt(result.length - 1) == "/"
      const preceedingSlashPresent = part.charAt(0) == "/"

      if (trailingSlashPresent) {
        if (preceedingSlashPresent) {
          result = result + part.substr(1)
        } else {
          result = result + part
        }
      } else {
        if (preceedingSlashPresent) {
          result = result + part
        } else {
          result = result + "/" + part
        }
      }
    })

    return result;
  }
}

Then when referencing URLs:

url.join(siteUrl, "something", "/something-else")

Combine multiple queries into one feed?

Is is possible to combine multiple queries into one generated feed?

Example below, pulling data from Contentful.

    {
      resolve: 'gatsby-plugin-feed-generator',
      options: {
        generator: `GatsbyJS`,
        rss: false, // Set to true to enable rss generation
        json: true, // Set to true to enable json feed generation
        siteQuery: `
      {
        site {
          siteMetadata {
            title
            description
            siteUrl
            author
          }
        }
      }
    `,
        feeds: [
          {
            name: 'feed',
            query: `
            {
              allContentfulPost(sort: { fields: [publishDate], order: DESC }, limit: 1) {
                edges {
                  node {
                  title
                  id
                  slug
                  publishDate(formatString: "MMMM DD, YYYY")
                  }
                }
              }
            },
            {
              allContentfulPhotography(sort: { fields: [publishDate], order: DESC }, limit: 1) {
                edges {
                  node {
                  title
                  id
                  slug
                  publishDate(formatString: "MMMM DD, YYYY")
                  }
                }
              }
            }
            `,
            normalize: ({ query: { site, allContentfulPost, allContentfulPhotography } }) => {
              return [allContentfulPost, allContentfulPhotography].edges.map(edge => {
                return {
                  title: edge.node.title,
                  url: site.siteMetadata.siteUrl + '/' + edge.node.slug,
                  date: edge.node.publishDate,
                }
              })
            },
          },

It works when running gatsby develop, but it fails when running gatsby build.

 ERROR #11321  PLUGIN

"gatsby-plugin-feed-generator" threw an error while running the onPostBuild lifecycle:

Cannot read property 'edges' of undefined

  55 |                       feedQuery = _context.sent;
  56 |                       query = (0, _extends3.default)({}, siteQuery, feedQuery);
> 57 |                       feedItems = feed.normalize({ query: query });
     |                                        ^
  58 |                       output = (0, _utils.buildFeed)((0, _extends3.default)({
  59 |                         site: site,
  60 |                         items: feedItems,

File: node_modules/gatsby-plugin-feed-generator/gatsby-node.js:57:40



  TypeError: Cannot read property 'edges' of undefined
  
  - gatsby-config.js:83 Object.normalize
    /Users/iammatthias/Sites/gatsby/net/gatsby-config.js:83:31
  
  - gatsby-node.js:57 _loop$
    [net]/[gatsby-plugin-feed-generator]/gatsby-node.js:57:40
  
  - runMicrotasks
  
  - task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5
  

not finished onPostBuild - 0.047s

I am currently generating multiple feeds in my Gatsby Config file: https://github.com/iammatthias/.com/blob/master/gatsby-config.js#L37 This works, but introduces the need to pull multiple feeds in a microblog project. If possible, I would like to combine the gatsby-plugin-feed-generator output into a single feed that provides information across my entire site.

Issues with react-helmet

When gasby develop'ing with this plugin, I'm seeing

Warning: Each child in an array or iterator should have a unique "key" prop.

Check the top-level render call using <head>. See https://fb.me/react-warning-keys for more information.
    in link
    in HTML

... in the terminal. A possible workaround might be to add data-react-helmet="true" to the <link> tags generated in gatsby-ssr.js

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.