From 552e10451676e0b1fdafaa7fd45b6d32171c6289 Mon Sep 17 00:00:00 2001 From: Nate Stewart Date: Thu, 29 Oct 2020 11:16:20 -0500 Subject: [PATCH] Graceful fallback for locale pages that don't exist --- pages/[...pages].tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pages/[...pages].tsx b/pages/[...pages].tsx index ad67d581a..0c1e5425c 100644 --- a/pages/[...pages].tsx +++ b/pages/[...pages].tsx @@ -19,11 +19,15 @@ export async function getStaticProps({ const data = pageItem && (await getPage({ variables: { id: pageItem.id! }, config, preview })) - const page = data?.page + let page = data?.page if (!page) { - // We throw to make sure this fails at build time as this is never expected to happen - throw new Error(`Page with slug '${slug}' not found`) + // Fallback to generating a page with direction to fix missing content for locale, so build process can continue + page = { + ...pages[0], + url: slug, + body: `*Missing content for locale* Add page with slug of ${slug} to resolve.` + } } return {