-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gatsby-plugin-sitemap: TypeError: Cannot use 'in' operator to search for 'nodes' in undefined #25019
Comments
Thank you for opening this, @janosh I think it happens because you've aliased gatsby/packages/gatsby-plugin-sitemap/src/internals.js Lines 23 to 25 in 670f92f
And it is actually mentioned in the plugin docs:
So the quick fix for you is to change We're marking this issue as answered and closing it for now but please feel free to reopen this and comment if you would like to continue this discussion. We hope we managed to help and thank you for using Gatsby! 💜 |
@vladar Good catch! Should have noticed that. But now I'm getting
with the following config options: {
output: `/sitemap.xml`,
query: `{
site {
siteMetadata {
url
}
}
allSitePage {
nodes {
path
}
}
}`,
resolveSiteUrl: ({ site }) => site.siteMetadata.url,
serialize: ({ site, allSitePage }) =>
allSitePage.nodes.map(node => ({ url: site.siteMetadata.url + node.path })),
} Both error messages weren't that helpful so far. |
Seems similar to #12912 |
Oh well, this seems weird for me but this plugin does this: gatsby/packages/gatsby-plugin-sitemap/src/internals.js Lines 57 to 69 in 6a9ffcc
as you see it forces url key to be But I do agree that this is super confusing. Feel free to submit a PR with additional validation that will provide better error messages in these cases! |
I was just about to say that. Why have a |
@moonmeister Do you have any context on this? (sorry if tagging inappropriately) |
I think gatsby/packages/gatsby-plugin-sitemap/src/gatsby-node.js Lines 40 to 60 in 6a9ffcc
If you do it this way around you first have to make all sorts of assumptions about the structure of the |
Maybe because |
But shouldn't serialize: ({ site, allSitePage }) =>
allSitePage.nodes.map(node => {
return {
url: `${site.wp.generalSettings.siteUrl}${node.path}`,
changefreq: `daily`,
priority: 0.7,
}
})
} and mine serialize: ({ site, allSitePage }) =>
allSitePage.nodes.map(node => ({ url: site.siteMetadata.url + node.path })), So you should be able to exclude based on the same patterns before and after serialization. |
Looks like you all discovered how internally trashed this plugin is. I ran into some of the issues you all have and did some work to try to resolve them (hence the docs note you found and the fact that you're not required to use There is an open RFC to fix these issues that needs finalizing, please catch up on that discussion and add you're feedback, it'd be much appreciated. If we can get the RFC finalized the work shouldn't take to much effort. |
Here's the PR where I tried to fix some issues, for context: #21948 |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Description
plugin-sitemap crashes build:
Steps to reproduce
My config (see in repo)
Environment
The text was updated successfully, but these errors were encountered: