fiix: move not-found into route groups
This commit is contained in:
8
app/[lang]/(preview)/not-found.tsx
Normal file
8
app/[lang]/(preview)/not-found.tsx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export default function NotFound() {
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<h2>Not Found</h2>
|
||||||
|
<p>Could not find requested resource</p>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -17,29 +17,30 @@ export default async function CurrentContentPage({
|
|||||||
searchParams,
|
searchParams,
|
||||||
}: PageArgs<LangParams, UriParams>) {
|
}: PageArgs<LangParams, UriParams>) {
|
||||||
try {
|
try {
|
||||||
const livePreviewHash = searchParams["live_preview"];
|
const livePreviewHash = searchParams["live_preview"]
|
||||||
if (livePreviewHash) {
|
if (!livePreviewHash) {
|
||||||
ContentstackLivePreview.setConfigFromParams(searchParams);
|
throw new Error("No hash found")
|
||||||
}
|
}
|
||||||
|
ContentstackLivePreview.setConfigFromParams(searchParams)
|
||||||
|
|
||||||
if (!searchParams.uri) {
|
if (!searchParams.uri) {
|
||||||
throw new Error("Bad URI");
|
throw new Error("Bad URI")
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await previewRequest<GetCurrentBlockPageData>(
|
const response = await previewRequest<GetCurrentBlockPageData>(
|
||||||
GetCurrentBlockPage,
|
GetCurrentBlockPage,
|
||||||
{ locale: params.lang, url: searchParams.uri }
|
{ locale: params.lang, url: searchParams.uri }
|
||||||
);
|
)
|
||||||
|
|
||||||
if (!response.data?.all_current_blocks_page?.total) {
|
if (!response.data?.all_current_blocks_page?.total) {
|
||||||
console.log("#### DATA ####");
|
console.log("#### DATA ####")
|
||||||
console.log(response.data);
|
console.log(response.data)
|
||||||
console.log("SearchParams URI: ", searchParams.uri);
|
console.log("SearchParams URI: ", searchParams.uri)
|
||||||
throw new Error("Not found");
|
throw new Error("Not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
const page = response.data.all_current_blocks_page.items[0];
|
const page = response.data.all_current_blocks_page.items[0]
|
||||||
const images = page.hero?.imagesConnection;
|
const images = page.hero?.imagesConnection
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -51,8 +52,9 @@ export default async function CurrentContentPage({
|
|||||||
<Aside blocks={page.aside} />
|
<Aside blocks={page.aside} />
|
||||||
</main>
|
</main>
|
||||||
</>
|
</>
|
||||||
);
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
return notFound();
|
return notFound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user