I'm building a dynamic Gatsby site with multiple languages through Contentful. I pass the page's ID in the pageContext object in my gatsby-node.js to fetch the necessary content on each page, but on the root URL / the data inside my pageContext object is missing.
In my index.js-file, the pageContext is empty on the root page /, with the exception of the parameter pageContext.isCreatedByStatefulCreatePages which is set to true. However, for every other page created in gatsby-node.js the pageContext object appears as it should.
I'm creating my pages in gatsby-node.js like this:
const baseUrl = locale === "da" ? "/" : `/${locale}/`
console.log(`${baseUrl}${slug ? slug : ""}`)
createPage({
path: `${baseUrl}${slug ? slug : ""}`,
component: path.resolve("./src/pages/index.js"),
context: {
id,
slug,
locale,
},
})
My above console.log outputs the following:
/virksomhed
/konsulent
/kontakt
/ <-- Page context is empty here
/om-os
/en/company
/en/consultant
/en/contact
/en/
/en/about-us
I can see that every page is created. On any other page than the index page ("/") the isCreatedByStatefulCreatePages is set to false.
I suspect that Gatsby somehow overrides the "createPage" for the root URL, but I wasn't able to find anything describing it in the documentation.
Anyone who have experience with this?