-
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
fix(gatsby-plugin-sitemap): Properly throw error on missing siteUrl #31963
Conversation
@@ -34,8 +34,8 @@ export function resolveSiteUrl(data) { | |||
if (!data?.site?.siteMetadata?.siteUrl) { | |||
throw Error( | |||
`\`siteUrl\` does not exist on \`siteMetadata\` in the data returned from the query. | |||
Add this to your custom query or provide a custom \`resolveSiteUrl\` function. | |||
https://www.gatsbyjs.com/plugins/gatsby-plugin-sitemap/#api-reference | |||
Add this to your \`siteMetadata\` object inside gatsby-config.js or add this to your custom query or provide a custom \`resolveSiteUrl\` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing indentation in this file
@@ -1,4 +1,7 @@ | |||
module.exports = { | |||
siteMetadata: { | |||
siteUrl: `https://www.yourdomain.tld`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create-gatsby
doesn't have the ability (yet) to define siteMetadata data for each plugin so for now this must be in here for everything (even when doesn't use sitemap plugin)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Description
Since the
resolvePages
function was before theresolveSiteUrl
function it couldn't throw the error about missingsiteUrl
. We also didn't show GraphQL errors if there were ones that we didn't account for. So I've added logging forerrors
, too. Lastly, I've addedsiteUrl
to our default and minimal starter.Documentation
I've updated the README a bit.
Related Issues
Fixes #31903
[ch32958]