From 33bb4fca97980142585c58ea049bc71fa3dd282c Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Mon, 20 May 2024 16:12:18 -0500 Subject: [PATCH] Create custom 500 page --- src/app/error.tsx | 11 ++++++++ src/app/not-found.tsx | 43 +++++++------------------------ src/components/HttpStatusPage.tsx | 39 ++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 src/app/error.tsx create mode 100644 src/components/HttpStatusPage.tsx diff --git a/src/app/error.tsx b/src/app/error.tsx new file mode 100644 index 00000000..eca15321 --- /dev/null +++ b/src/app/error.tsx @@ -0,0 +1,11 @@ +'use client'; + +import HttpStatusPage from '@/components/HttpStatusPage'; + +export default function Error() { + return ( + + Something went wrong + + ); +} diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 7d188b74..aca6aeaa 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,45 +1,22 @@ 'use client'; -import SiteGrid from '@/components/SiteGrid'; -import { PATH_ROOT } from '@/site/paths'; +import HttpStatusPage from '@/components/HttpStatusPage'; import { clsx } from 'clsx/lite'; -import Link from 'next/link'; import { usePathname } from 'next/navigation'; export default function NotFound() { const pathname = usePathname(); return ( - + -

- 404 -

-
-
- - {pathname} - - {' '} - could not be found -
- - Return Home - -
- - } /> + {pathname} +
+ {' '} + could not be found + ); } diff --git a/src/components/HttpStatusPage.tsx b/src/components/HttpStatusPage.tsx new file mode 100644 index 00000000..0abe6ec0 --- /dev/null +++ b/src/components/HttpStatusPage.tsx @@ -0,0 +1,39 @@ +import { ReactNode } from 'react'; +import SiteGrid from './SiteGrid'; +import { clsx } from 'clsx/lite'; +import { PATH_ROOT } from '@/site/paths'; +import Link from 'next/link'; + +export default function HttpStatusPage({ + status, + children, +}: { + status: number + children?: ReactNode +}) { + return ( + +

+ {status} +

+
+ {children && +
{children}
} + + Return Home + +
+ + } /> + ); +}