From c0b7f57c8a4e78bd88a9cc85ed13b539b298e6b3 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Thu, 8 Feb 2024 11:54:17 +0100 Subject: [PATCH] fiix: move not-found into route groups --- app/[lang]/{ => (live)}/not-found.tsx | 0 app/[lang]/(preview)/not-found.tsx | 8 ++++++++ app/[lang]/(preview)/preview/page.tsx | 26 ++++++++++++++------------ 3 files changed, 22 insertions(+), 12 deletions(-) rename app/[lang]/{ => (live)}/not-found.tsx (100%) create mode 100644 app/[lang]/(preview)/not-found.tsx diff --git a/app/[lang]/not-found.tsx b/app/[lang]/(live)/not-found.tsx similarity index 100% rename from app/[lang]/not-found.tsx rename to app/[lang]/(live)/not-found.tsx diff --git a/app/[lang]/(preview)/not-found.tsx b/app/[lang]/(preview)/not-found.tsx new file mode 100644 index 000000000..1a6cc1ce6 --- /dev/null +++ b/app/[lang]/(preview)/not-found.tsx @@ -0,0 +1,8 @@ +export default function NotFound() { + return ( +
+

Not Found

+

Could not find requested resource

+
+ ) +} diff --git a/app/[lang]/(preview)/preview/page.tsx b/app/[lang]/(preview)/preview/page.tsx index 449e25818..1f1a7e15d 100644 --- a/app/[lang]/(preview)/preview/page.tsx +++ b/app/[lang]/(preview)/preview/page.tsx @@ -17,29 +17,30 @@ export default async function CurrentContentPage({ searchParams, }: PageArgs) { try { - const livePreviewHash = searchParams["live_preview"]; - if (livePreviewHash) { - ContentstackLivePreview.setConfigFromParams(searchParams); + const livePreviewHash = searchParams["live_preview"] + if (!livePreviewHash) { + throw new Error("No hash found") } + ContentstackLivePreview.setConfigFromParams(searchParams) if (!searchParams.uri) { - throw new Error("Bad URI"); + throw new Error("Bad URI") } const response = await previewRequest( GetCurrentBlockPage, { locale: params.lang, url: searchParams.uri } - ); + ) if (!response.data?.all_current_blocks_page?.total) { - console.log("#### DATA ####"); - console.log(response.data); - console.log("SearchParams URI: ", searchParams.uri); - throw new Error("Not found"); + console.log("#### DATA ####") + console.log(response.data) + console.log("SearchParams URI: ", searchParams.uri) + throw new Error("Not found") } - const page = response.data.all_current_blocks_page.items[0]; - const images = page.hero?.imagesConnection; + const page = response.data.all_current_blocks_page.items[0] + const images = page.hero?.imagesConnection return ( <> @@ -51,8 +52,9 @@ export default async function CurrentContentPage({