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,
|
||||
}: PageArgs<LangParams, UriParams>) {
|
||||
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<GetCurrentBlockPageData>(
|
||||
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({
|
||||
<Aside blocks={page.aside} />
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return notFound();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user