Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
feat(i18n): fix custom 404 pages
Browse files Browse the repository at this point in the history
  • Loading branch information
CanRau committed Dec 1, 2018
1 parent 25f3826 commit a3649f6
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,25 @@ exports.createPages = async ({ actions, getNodes, graphql }) => {

// console.log(`${slug} => ${url}`)

const component = resolve(`./src/templates/${layout}.js`)
const context = { url, slug, lang }

createPage({ component, path: url, context })
const page = {
component: resolve(`./src/templates/${layout}.js`),
path: url,
context: { url, slug, lang },
}
// https://github.com/gatsbyjs/gatsby/issues/5129#issuecomment-442397391
if (slug === `404`) {
page.matchPath = `/${lang}/*`
}
createPage(page)

// create root 404
slug === `404` &&
lang === `en` &&
createPage({
component,
path: `/404`,
context,
})
// slug === `404` &&
// lang === `en` &&
// createPage({
// component,
// path: `/404`,
// context,
// })

createNodeField({
node,
Expand Down

0 comments on commit a3649f6

Please sign in to comment.