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): include path prefix #12852

Merged
merged 4 commits into from
Mar 27, 2019

Conversation

bennetthardwick
Copy link
Contributor

Description

The Gatsby sitemap plugin can be configured to split up all of the sites URLs into smaller sitemaps, all being referenced from a main "index" sitemap. Unfortunately, this index sitemap doesn't take the pathPrefix option into account and will never link to the correct "child" sitemaps.

As sitemap.js doesn't have an option for pathPrefix, this change appends the pathPrefix to the site's hostname when more than one sitemap needs to be created.

Include path prefix in the index sitemap created by
gatsby-plugin-sitemap.
@bennetthardwick
Copy link
Contributor Author

@gatsbyjs/core is there any chance someone can take a look at this?

@bennetthardwick bennetthardwick requested a review from a team March 27, 2019 00:38
@pieh pieh self-assigned this Mar 27, 2019
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

LGTM! thanks for fixing! let's wait for tests to finish

}
const prefix = `/test`
await onPostBuild({ graphql, pathPrefix: prefix }, options)
expect(sitemapSpy.mock.calls[0][0].hostname).toEqual(
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: don't need to change this (we do use it in different places as well), but for future, please use

expect(sitemapSpy).toBeCalledWith(
  expect.objectContaining({
    hostname: `${queryResult.data.site.siteMetadata.siteUrl}${prefix}`
  })
)

reaching to .mock.calls[0][0] works, but is less readable

@pieh pieh merged commit 1d7e6c7 into gatsbyjs:master Mar 27, 2019
@bennetthardwick bennetthardwick deleted the fix/gatsby-sitemap-index branch March 28, 2019 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants