diff --git a/packages/gatsby-plugin-sitemap/src/__tests__/internals.js b/packages/gatsby-plugin-sitemap/src/__tests__/internals.js index 8b047261d2c74..7a8b5652f25be 100644 --- a/packages/gatsby-plugin-sitemap/src/__tests__/internals.js +++ b/packages/gatsby-plugin-sitemap/src/__tests__/internals.js @@ -137,6 +137,16 @@ describe(`results using non default alternatives`, () => { }, ], }, + otherData: { + nodes: [ + { + name: `test`, + }, + { + name: `test 2`, + }, + ], + }, }, } } @@ -161,5 +171,6 @@ describe(`results using non default alternatives`, () => { const queryRecords = filterQuery(results, [], ``, customSiteResolver) expect(queryRecords.site.siteMetadata.siteUrl).toEqual(customUrl) + expect(queryRecords).toHaveProperty(`otherData`) }) }) diff --git a/packages/gatsby-plugin-sitemap/src/internals.js b/packages/gatsby-plugin-sitemap/src/internals.js index 8e61b4afec0cc..7b5a8356a8425 100644 --- a/packages/gatsby-plugin-sitemap/src/internals.js +++ b/packages/gatsby-plugin-sitemap/src/internals.js @@ -20,7 +20,9 @@ export function filterQuery( throw new Error(errors.join(`, `)) } - let { allPages, originalType } = getNodes(data.allSitePage) + const { allSitePage, ...otherData } = data + + let { allPages, originalType } = getNodes(allSitePage) // Removing excluded paths allPages = allPages.filter( @@ -53,6 +55,7 @@ export function filterQuery( siteUrl = withoutTrailingSlash(siteUrl) return { + ...otherData, allSitePage: { [originalType]: originalType === `nodes`