diff --git a/src/pages/_error.tsx b/src/pages/_error.tsx index f977fb0..353832f 100644 --- a/src/pages/_error.tsx +++ b/src/pages/_error.tsx @@ -1,20 +1,33 @@ import { ThemeSwitcher } from '@/components/ThemeSwitcher' import FadeIn from 'react-fade-in' import Link from 'next/link' +import type { ErrorProps } from '@/utils/interface' +import type { GetServerSideProps, GetServerSidePropsContext } from 'next' -export default function Error() { +const ErrorPage: React.FC = ({ statusCode }) => { return ( <>
-

404

+

{statusCode}

-

This page could not be found.

-

- {'<-- Home'} -

+ {statusCode === 404 ? ( + <> +

This page could not be found.

+

+ {'<-- Home'} +

+ + ) : ( + <> +

An unexpected error occurred.

+

+ {'<-- Home'} +

+ + )}
@@ -22,3 +35,12 @@ export default function Error() { ) } + +export const getServerSideProps: GetServerSideProps = async ( + context: GetServerSidePropsContext +) => { + const statusCode = context.res ? context.res.statusCode : 404 + return { props: { statusCode } } +} + +export default ErrorPage