From 9c96bc73f20beee79438eb0dbbbc01b854c75837 Mon Sep 17 00:00:00 2001 From: dragonworr Date: Wed, 30 Dec 2020 02:48:56 +0530 Subject: [PATCH] Fixes styxlab/next-cms-ghost#6 --- pages/[...slug].tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pages/[...slug].tsx b/pages/[...slug].tsx index 8e59b4c..afeccd9 100644 --- a/pages/[...slug].tsx +++ b/pages/[...slug].tsx @@ -94,7 +94,11 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { if (dimensions) contactPage.featureImage = { url, dimensions } } } - if (!post && !page && !isContactPage) throw new Error(`Expected post or page for slug: ${slug}`) + if (!post && !page && !isContactPage) { + return { + notFound: true, + } + } let previewPosts: GhostPostsOrPages | never[] = [] let prevPost: GhostPostOrPage | null = null @@ -166,6 +170,6 @@ export const getStaticPaths: GetStaticPaths = async () => { return { paths, - fallback: enable + fallback: enable && "blocking" } }