From 0ae029de406176439de800ccff5e966db882b013 Mon Sep 17 00:00:00 2001 From: Sean Ho Date: Mon, 26 Jul 2021 17:52:02 +0800 Subject: [PATCH 1/3] ignore besquare page when building locale pages --- gatsby-node.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gatsby-node.js b/gatsby-node.js index 33592b6d095..45433e8881a 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -104,6 +104,7 @@ exports.onCreatePage = ({ page, actions }) => { const is_production = process.env.GATSBY_ENV === 'production' const careers_regex = /^[a-z-]+\/careers\//g const endpoint_regex = /^[a-z-]+\/endpoint\//g + const besquare_regex = /^[a-z-]+\/besquare\//g const offline_plugin_regex = /^[a-z-]+\/offline-plugin-app-shell-fallback/g if (is_production) { @@ -112,6 +113,7 @@ exports.onCreatePage = ({ page, actions }) => { if ( careers_regex.test(localized_path) || endpoint_regex.test(localized_path) || + besquare_regex.test(localized_path) || offline_plugin_regex.test(localized_path) ) return From c703b6663ccd43d6d05e981a39a7877e707c1aaf Mon Sep 17 00:00:00 2001 From: Sean Ho Date: Wed, 28 Jul 2021 09:56:31 +0800 Subject: [PATCH 2/3] remove localized besquare pages from sitemap --- gatsby-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatsby-config.js b/gatsby-config.js index 75a9245aecd..8f20862e709 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -71,7 +71,7 @@ module.exports = { ], serialize: ({ site, allSitePage }) => allSitePage.edges.map((edge) => { - const ignore_localized_regex = /careers/ + const ignore_localized_regex = /careers|besquare/ const path = edge.node.path let priority = 0.7 const languages = Object.keys(language_config) From 79d5d74e4bb3bfea88787c57cc93e65305a65528 Mon Sep 17 00:00:00 2001 From: Sean Ho Date: Wed, 28 Jul 2021 10:33:37 +0800 Subject: [PATCH 3/3] refactor excluded pages regex into a single variable --- gatsby-node.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 45433e8881a..e1e82484276 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -102,21 +102,13 @@ exports.onCreatePage = ({ page, actions }) => { const { path, is_default } = language_config[lang] const localized_path = is_default ? page.path : `${path}${page.path}` const is_production = process.env.GATSBY_ENV === 'production' - const careers_regex = /^[a-z-]+\/careers\//g - const endpoint_regex = /^[a-z-]+\/endpoint\//g - const besquare_regex = /^[a-z-]+\/besquare\//g - const offline_plugin_regex = /^[a-z-]+\/offline-plugin-app-shell-fallback/g + const excluded_pages_regex = + /^[a-z-]+\/(careers|endpoint|offline-plugin-app-shell-fallback|besquare)\//g if (is_production) { if (path === 'ach') return } - if ( - careers_regex.test(localized_path) || - endpoint_regex.test(localized_path) || - besquare_regex.test(localized_path) || - offline_plugin_regex.test(localized_path) - ) - return + if (localized_path.match(excluded_pages_regex)) return if (!translations_cache[lang]) { const translation_json = require(`./src/translations/${lang}`)