Gatsby-plugin-sitemap generates NaN-NaN-NaN on <lastmod>
See original GitHub issueDescription
When using gatsby-plugin-sitemap
to generate sitemap.xml, <lastmod>
was not available by default.
Manually adding this would output <lastmod>
tags in the final sitemap.xml, but the date were written as NaN-NaN-NaN
Note: Even if we manually uses lastmod: '2020-08-03T01:54:49.000Z'
during the serialize below still outputs as NaN
Steps to reproduce
{
resolve: `gatsby-plugin-sitemap`,
options: {
createLinkInHead: true,
query: `{
site {
siteMetadata {
siteUrl
}
}
allSitePage {
nodes {
path
context {
updated
}
}
}
}`,
resolveSiteUrl: ({ site }) => {
return site.siteMetadata.siteUrl;
},
serialize: ({ site, allSitePage }) =>
allSitePage.nodes.map((node) => {
return {
url: `${site.siteMetadata.siteUrl}${node.path}`,
changefreq: `daily`,
priority: 0.7,
lastmod: `${node.context.updated}`,
};
}),
},
},
Expected result
Expecting the sitemap to output entries with correct last-modified tags, ie:<lastmod>2020-08-03T01:54:49.000Z</lastmod>
Actual result
<lastmod>NaN-NaN-NaN</lastmod>
Environment
System: OS: macOS 10.15.6 CPU: (8) x64 Intel® Core™ i7-6820HQ CPU @ 2.70GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.17.0 - ~/.nvm/versions/node/v12.17.0/bin/node npm: 6.14.7 - ~/.nvm/versions/node/v12.17.0/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 84.0.4147.105 Safari: 13.1.2 npmPackages: gatsby: ^2.24.4 => 2.24.4 gatsby-image: ^2.4.13 => 2.4.13 gatsby-plugin-catch-links: ^2.3.11 => 2.3.11 gatsby-plugin-feed-mdx: ^1.0.1 => 1.0.1 gatsby-plugin-google-analytics: ^2.3.11 => 2.3.11 gatsby-plugin-manifest: ^2.4.18 => 2.4.21 gatsby-plugin-mdx: ^1.2.27 => 1.2.27 gatsby-plugin-offline: ^3.2.18 => 3.2.18 gatsby-plugin-preact: ^4.0.9 => 4.0.9 gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10 gatsby-plugin-robots-txt: ^1.5.1 => 1.5.1 gatsby-plugin-s3: ^0.3.3 => 0.3.4 gatsby-plugin-sharp: ^2.6.19 => 2.6.22 gatsby-plugin-sitemap: ^2.4.11 => 2.4.11 gatsby-plugin-styled-components: ^3.3.10 => 3.3.10 gatsby-remark-attr: ^0.1.0 => 0.1.0 gatsby-remark-external-links: 0.0.4 => 0.0.4 gatsby-remark-images: ^3.3.19 => 3.3.19 gatsby-remark-unwrap-images: ^1.0.2 => 1.0.2 gatsby-source-filesystem: ^2.3.20 => 2.3.23 gatsby-transformer-sharp: ^2.5.11 => 2.5.11 npmGlobalPackages: gatsby-cli: 2.12.66
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
@fgambarino Thank you so much. That fixes my problem.
Was wondering why isn’t there any documentation regarding to this on the plugin page itself. Whether is it
lastmod
orlastmodISO
, I felt that it’s somewhat important for users.Also,
and sorry @vladar I’m unable to create a minimal reproduction for this issue.
In case anyone that came across similar problem, this solved my problem:
via the lastmodISO
Hiya!
This issue has gone quiet. Spooky quiet. 👻
We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label “not stale” to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 💪💜