Skip to content
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

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

LekoArts
Copy link
Contributor

Description

Since the resolvePages function was before the resolveSiteUrl function it couldn't throw the error about missing siteUrl. We also didn't show GraphQL errors if there were ones that we didn't account for. So I've added logging for errors, too. Lastly, I've added siteUrl to our default and minimal starter.

Documentation

I've updated the README a bit.

Related Issues

Fixes #31903
[ch32958]

@LekoArts LekoArts added the topic: plugins Related to plugin system, themes & catch-all for plugins that don't have a label label Jun 17, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 17, 2021
@LekoArts LekoArts changed the title better siteUrl error message + update starters fix(gatsby-plugin-sitemap): Properly throw error on missing siteUrl Jun 17, 2021
@LekoArts LekoArts removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 17, 2021
@@ -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.
Copy link
Contributor Author

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`,
Copy link
Contributor Author

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)

Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@vladar vladar merged commit f91dd52 into master Jun 18, 2021
@vladar vladar deleted the sitemap-siteurl branch June 18, 2021 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: plugins Related to plugin system, themes & catch-all for plugins that don't have a label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gatsby-plugin-sitemap not generating sitemap with default options when running yarn build
2 participants