-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Description
Summary
I implemented gatsby-plugin-sitemap onto my site just now, and I ran into a few problems that I think could've been prevented by improving documentation and adding some error handling with logging in the plugin.
First, I was unclear that it is required to query allSitePage with a path property. The docs do state this, however as devs do, we typically skim documentation. Would be good to add error handling/logging when the allSitePage option is missing.
Second, I forgot to return from the serialize function, which led to this error. I think this could be improved with some error handling. If urls is undefined, throw an error with a message "gatsby-plugin-sitemap did not recieve sitemap entries. Did you forget to return from your serialize function". Or something of that nature.
ERROR #11321 PLUGIN
"gatsby-plugin-sitemap" threw an error while running the onPostBuild lifecycle:
Cannot read property 'forEach' of undefined
79 |
80 | map = _sitemap.default.createSitemap(rest);
> 81 | urls.forEach(function (u) {
| ^
82 | return map.add(u);
83 | });
84 | return _context.abrupt("return", (0, _internals.writeFile)(saved,
map.toString()));
File: node_modules\gatsby-plugin-sitemap\gatsby-node.js:81:18Motivation
To improve DX when implementing the sitemap plugin
Steps to resolve this issue
I will be cooking up a pull request for your consideration to resolve these issues 👍