mirror of
https://github.com/vercel/commerce.git
synced 2025-06-29 18:01:21 +00:00
Graceful fallback for locale pages that don't exist
This commit is contained in:
parent
629df7a9ab
commit
552e104516
@ -19,11 +19,15 @@ export async function getStaticProps({
|
|||||||
const data =
|
const data =
|
||||||
pageItem &&
|
pageItem &&
|
||||||
(await getPage({ variables: { id: pageItem.id! }, config, preview }))
|
(await getPage({ variables: { id: pageItem.id! }, config, preview }))
|
||||||
const page = data?.page
|
let page = data?.page
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
// We throw to make sure this fails at build time as this is never expected to happen
|
// Fallback to generating a page with direction to fix missing content for locale, so build process can continue
|
||||||
throw new Error(`Page with slug '${slug}' not found`)
|
page = {
|
||||||
|
...pages[0],
|
||||||
|
url: slug,
|
||||||
|
body: `*Missing content for locale* Add page with slug of ${slug} to resolve.`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user