I'm having a hard time with slices interferring with my /404.html template
I am building a Gatsby + WordPress + Polylang site (multilingual)
I have created some multilingual Header / footer menus in slices which I pass to my createPage
I have overrided my 404.js template by passing the slices (see below) and it works for the production 404 page
// override 404 and home page behavior for slices
exports.onCreatePage = async ({ page, actions }) => {
const { createPage, deletePage } = actions;
// Check if the page is a localized 404
if (page.path.includes("404") || page.path === "/") {
const oldPage = { ...page };
// Get the language code from the path, and match all paths
// starting with this code (apart from other valid paths)
// const langCode = page.path.split(`/`)[1]
// page.matchPath = `/${langCode}/*`
// Add slices to these pages
(page.slices = {
"header-main": `menu-principal-fr`,
"header-partners": `menu-partners-fr`,
"footer-main": `menu-footer-fr`,
}),
// Recreate the modified page
deletePage(oldPage);
createPage(page);
}
};
However I still got an error for the /404.html template which I don't know how to override
ERROR UNKNOWN
Could not find slice "header-main" used by page "/404.html".
Please check your createPages in your gatsby-node to verify this
is the correct name or set allowEmpty to true.
[ ] 0.12 0/ 0 Writing page-data.json
Error: Could not find slice "header-main" used by page "/404.htm
l". Please check your createPages in your gatsby-node to verify
this is the correct name or set allowEmpty
to true.
It seems my ovverride does'nt apply to /404.html
Thanks for any help
PS: I did not start the build of multilingual 404 pages yet