From f7067f6134a8ae13dc5b476614771be6d05318b6 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 7 Mar 2016 10:03:41 -0800 Subject: [PATCH] Install wildcard handler if path includes '/404' --- lib/isomorphic/create-routes.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/isomorphic/create-routes.js b/lib/isomorphic/create-routes.js index a03e3ea5575df..7d3b2a3137d97 100644 --- a/lib/isomorphic/create-routes.js +++ b/lib/isomorphic/create-routes.js @@ -20,6 +20,7 @@ module.exports = (files, pagesReq) => { pages, templates, } + let notFound = null const templatesHash = {} templatesHash.root = routes templatesHash['/'] = routes @@ -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 }