Skip to content

Commit

Permalink
exclude offline plugin app shell from sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Fetten committed Feb 3, 2018
1 parent e9809fc commit 77091f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/gatsby-plugin-sitemap/src/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { regexExclude404 } = require(`../internals`)
const { regexExclude404AndOfflineShell } = require(`../internals`)

describe(`gatsby-plugin-sitemap`, () => {
it(`regex for filtering out 404 pages`, () => {
const regex = new RegExp(regexExclude404)
const regex = new RegExp(regexExclude404AndOfflineShell)

// 404 pages
expect(regex.exec(`/404`)).toBeNull()
Expand All @@ -11,9 +11,13 @@ describe(`gatsby-plugin-sitemap`, () => {
expect(regex.exec(`/404page`)).toBeNull()
expect(regex.exec(`/404-and-now-anything`)).toBeNull()

// gatsby-plugin-offline app shell fallback
expect(regex.exec(`/offline-plugin-app-shell-fallback`)).toBeNull()

// Generic valid pages
expect(regex.exec(`/my-page`)).not.toBeNull()
expect(regex.exec(`/my-page-404123`)).not.toBeNull()
expect(regex.exec(`/my-page-404`)).not.toBeNull()
expect(regex.exec(`/my-offline-plugin-app-shell-fallback`)).not.toBeNull()
})
})
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-sitemap/src/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const runQuery = (handler, query) =>
return r.data
})

export const regexExclude404 = /^(?!\/(dev-404-page|404)).*$/
export const regexExclude404AndOfflineShell = /^(?!\/(dev-404-page|404|offline-plugin-app-shell-fallback)).*$/

export const defaultOptions = {
query: `
Expand All @@ -26,7 +26,7 @@ export const defaultOptions = {
allSitePage(
filter: {
path: {
regex: "${regexExclude404}"
regex: "${regexExclude404AndOfflineShell}"
}
}
) {
Expand Down

0 comments on commit 77091f7

Please sign in to comment.