diff --git a/gatsby-node.js b/gatsby-node.js index 78239374..cce9e791 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -10,7 +10,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => { edges { node { fields { - fileRelativePath slug } id @@ -39,12 +38,22 @@ exports.createPages = async ({ actions, graphql, reporter }) => { context: { id, layout: 'QuickStartLayout', - fileRelativePath, }, }); }); }; +exports.onCreatePage = async ({ page, actions }) => { + const { createPage, deletePage } = actions; + const oldPage = { ...page }; + + if (page.path === '/') { + page.context.layout = 'QuickStartLayout'; + } + deletePage(oldPage); + createPage(page); +}; + exports.onCreateNode = ({ node, actions }) => { const { createNodeField } = actions; diff --git a/package.json b/package.json index 30f5c9e1..b8b42e01 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ ], "scripts": { "develop": "GATSBY_NEWRELIC_ENV=development gatsby develop", - "start": "gatsby develop", + "start": "yarn develop", "build": "GATSBY_NEWRELIC_ENV=production gatsby build", "build:production": "yarn build --prefix-paths", "serve": "gatsby serve", diff --git a/src/layouts/index.js b/src/layouts/index.js index 18517fc8..e3868328 100644 --- a/src/layouts/index.js +++ b/src/layouts/index.js @@ -3,11 +3,11 @@ import QuickStartLayout from './QuickStartLayout'; import PropTypes from 'prop-types'; const Layout = ({ children, pageContext }) => { - if (pageContext.fileRelativePath.match(/404/)) { - return children; + if (pageContext.layout === 'QuickStartLayout') { + return {children}; } - return {children}; + return <>{children}; }; Layout.propTypes = {