What is the best practice to render a 404 page in Gatsby when a page exists in the default language, but a prismic translation hasn't been created yet?
We are using gatsby-node to delete the original and regenerate all pages in all locales, so some of them exist as url but the frontend shows us a blank page because the content is not there yet.
Is there a better approach to the following code? I would love to avoid adding conditional rendering in every page.
How are you handling the dynamical generation of pages, are you using the uids of the docs? And, are you creating a route for all existing pages based on the number of languages on your repo?
Thank you.
Not all of our pages are generated by gatsby-node, in fact, most of them are not, so we don't generate them via a graphql query in gatsby-node and there is no place where we can query the metadata of a document in order to check if they have alternateLangues. How would you proceed with those pages that are not generated via gatsby-node?
I see, could you tell me how are you generating all the other pages, are you using any of the Gatsby plugins that work with Prismic?
gatsby-source-prismic
gatsby-source-prismic-graphql
In the last one, pages are generated dynamically with the help of the plugin, and you access to the metadata in the queries, as you would in any other GraphQL query.
Could you show me an example of how you're generating the queries so I have a better idea?
We two types of pages: the static ones and the dynamic ones.
Dynamic ones are generated in gatsby-node. Here is a snippet of how it looks like.
The static ones are under the /src/pages directory and they are doing their queries. They have different layouts, it makes no sense for us to generate them under gatsby-node.
Ok, well, the thing is that, if the document does not exist, the route shouldn’t exist either. We're working on a multi language project that will soon use the same plugin that you're using.
Right now you can still see the un official code of the project to check the stucture of how dynamic multi locale pages are generated. Here's the project code, check the gatsby-node. Right now, if you hit a url for a doc that doesn't exist, you'll get the default gatsby 404 page, (Read the official Gatsby docs: Adding a 404 page).
Pau
closed , flag & select 'Something Else' to reopen.
9
This issue has been closed due to inactivity. Flag to reopen.