Skip to content

Commit

Permalink
Merge pull request #121 from scottnonnenberg/not-found
Browse files Browse the repository at this point in the history
Allow /404 file to act as wildcard route
  • Loading branch information
KyleAMathews committed Mar 7, 2016
2 parents 1e44024 + f7067f6 commit 0b5bed5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/isomorphic/create-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = (files, pagesReq) => {
pages,
templates,
}
let notFound = null
const templatesHash = {}
templatesHash.root = routes
templatesHash['/'] = routes
Expand Down Expand Up @@ -159,7 +160,22 @@ module.exports = (files, pagesReq) => {
parentTemplateFile,
})
}

if (includes(page.path, '/404')) {
notFound = {
path: '*',
component: handler,
page,
pages,
templates,
parentTemplateFile,
}
}
})

if (notFound) {
routes.childRoutes.push(notFound)
}

return routes
}

0 comments on commit 0b5bed5

Please sign in to comment.