diff --git a/pages/500.tsx b/pages/_error.tsx similarity index 85% rename from pages/500.tsx rename to pages/_error.tsx index 4d849ef..b14eb1f 100644 --- a/pages/500.tsx +++ b/pages/_error.tsx @@ -1,8 +1,9 @@ -import type { NextPage } from "next"; +import { NextPage, NextPageContext } from "next"; import Link from "next/link"; import styles from "../styles/Errorpage.module.css"; -const svg = ` +const Error: NextPage<{ statusCode?: number }> = ({ statusCode }) => { + const svg = ` @@ -52,7 +53,7 @@ const svg = ` - 500 + ${statusCode ? statusCode : "???"} @@ -63,17 +64,22 @@ const svg = ` `; -const Custom404: NextPage = () => { return
-
+
- The site you requested could not be found.
+ { statusCode === 404 ? "The site you requested could not be found." : "An error occurred." } +
> Back to the main page <
; }; -export default Custom404; \ No newline at end of file +Error.getInitialProps = ({ res, err }: NextPageContext) => { + const statusCode = res ? res.statusCode : err ? err.statusCode : 404; + return { statusCode }; +}; + +export default Error; \ No newline at end of file