From 22864473f1cc682dd0ddc25ded291e6e321e02cd Mon Sep 17 00:00:00 2001 From: Ran Byron Date: Sat, 23 Jan 2021 20:32:51 +0200 Subject: [PATCH] Allow stand-alone pages --- src/gatsby-node.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gatsby-node.js b/src/gatsby-node.js index 4f7af36..ab7758c 100644 --- a/src/gatsby-node.js +++ b/src/gatsby-node.js @@ -91,6 +91,19 @@ exports.onCreatePage = async ({ page, actions }, pluginOptions) => { } } + // get first dir name + const [_, pageDir] = page.path.match(/^\/([^\/]*)/) || [] + + // if it matches an intl language + // this page will be opted out of additional page generation + if (languages.includes(pageDir)) { + // recreate the page as is but with correct language context + const newPage = generatePage(false, pageDir) + deletePage(page) + createPage(newPage) + return + } + const newPage = generatePage(false, defaultLanguage) deletePage(page) createPage(newPage)