gatsby-plugin-feed-generator
gatsby-plugin-feed-generator copied to clipboard
`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
@holmberd Currently it is set up to require that you pass in a date for each item in the feed. Do you have a use case where this is a problem?
@markmichon I ran into this too. I am using this feed to power a 'dynamic' react app in the Gatsby site that can not be generated statically. Essentially it's a view that needs to be searchable & filterable. Probably not the use case for this plugin, but it works.
Anyways, would it be possible to remove the date requirement? To get around it for now I just added the date back and added a Date.now() timestamp so there's something there and it build fine. I am just ignoring it in my app.
By the way, thanks for the plugin! I really appreciate it.
@markmichon Actually I don't think this plugin's intension was to generate any content, but content like blog posts. I noticed in your plugin it's hardcoded to only display the title, link, description, content, id and date. I was hoping any fields/content is queried and pulled into the feed will be displayed, but doesn't look that's a possibility.
@brentrobbins Ah okay. It's not documented, but technically you can pass more options in https://github.com/markmichon/gatsby-plugin-feed-generator/blob/master/src/utils.js#L22
As long as they map nicely to anything used by the feed library they should work.
Happy to accept a PR if you want to make all those defaults fallback to nothing.
But to your first point, yeah this runs at build time, so anything that happens live isn't going to show up.
@markmichon So would this work to display anything for the items? Here's what I am trying to display:
normalize: ({ query: { site, allMarkdownRemark } }) => {
return allMarkdownRemark.edges.map(edge => {
return {
title: edge.node.frontmatter.title,
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
last_name: edge.node.frontmatter.last_name,
job_title: edge.node.frontmatter.job_title,
credentials: edge.node.frontmatter.credentials,
bio: edge.node.frontmatter.bio,
procedures_performed: edge.node.frontmatter.procedures_performed,
address: edge.node.frontmatter.address,
city: edge.node.frontmatter.city,
state: edge.node.frontmatter.state,
zipcode: edge.node.frontmatter.zipcode,
website: edge.node.frontmatter.website,
date: Date.now()
}
})
},
@brentrobbins I'm not sure the feed dependency we're using supports custom categories in rss.
If you're mostly just looking for XML(or JSON for that matter) as your output type, it might be better to roll your own plugin so you don't have to fight with the RSS spec or JSON feed spec.
@markmichon right I am looking for a more custom JSON output. Thanks for your help though. I appreciate it.