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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow single-language pages #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down