www: port error pages to Fresh 2 (#2456)

Forgot to port the `_500.tsx` and `_400.tsx` error pages to Fresh 2
This commit is contained in:
Marvin Hagemeister
2024-05-24 17:31:52 +02:00
committed by GitHub
parent c9f0ccdce7
commit 484d918307
2 changed files with 14 additions and 11 deletions
+46
View File
@@ -0,0 +1,46 @@
import { HttpError, type PageProps } from "@fresh/core";
import LemonDrop from "../islands/LemonDrop.tsx";
export function ServerCodePage(
props: { serverCode: number; codeDescription: string },
) {
return (
<>
<section>
<div class="w-full flex justify-center items-center flex-col bg-green-300">
<LemonDrop />
</div>
<div class="text-center">
<h1 class="text-6xl md:text-9xl font-extrabold">
{props.serverCode}
</h1>
<p class="p-4 text-2xl md:text-3xl">
{props.codeDescription}
</p>
<p class="p-4">
<a href="/" class="hover:underline">Back to the Homepage</a>
</p>
</div>
</section>
</>
);
}
export default function PageNotFound(props: PageProps) {
const error = props.error;
if (error instanceof HttpError) {
if (error.status === 404) {
return ServerCodePage({
serverCode: 404,
codeDescription: "Couldn’t find what you’re looking for.",
});
}
}
return ServerCodePage({
serverCode: 500,
codeDescription: "Oops! Something went wrong.",
});
}