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({