* Add 404 and 500 page Co-authored-by: hashrock <hashrock@users.noreply.github.com>
This commit is contained in:
co-authored by
hashrock
parent
55f657827f
commit
3431555f95
@@ -0,0 +1,38 @@
|
||||
/** @jsx h */
|
||||
/** @jsxFrag Fragment */
|
||||
import { Fragment, h } from "preact";
|
||||
import LemonDrop from "../islands/LemonDrop.tsx";
|
||||
|
||||
export function ServerCodePage(
|
||||
props: { serverCode: number; codeDescription: string },
|
||||
) {
|
||||
return (
|
||||
<Fragment>
|
||||
<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>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export default function PageNotFound() {
|
||||
return ServerCodePage({
|
||||
serverCode: 404,
|
||||
codeDescription: "Couldn't find what you're looking for.",
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { ServerCodePage } from "./_404.tsx";
|
||||
|
||||
export default function InternalServerError() {
|
||||
return ServerCodePage({
|
||||
serverCode: 500,
|
||||
codeDescription: "Oops! Something went wrong.",
|
||||
});
|
||||
}
|
||||
@@ -34,9 +34,7 @@ export const handler: Handlers<Data> = {
|
||||
}
|
||||
const entry = TABLE_OF_CONTENTS[slug];
|
||||
if (!entry) {
|
||||
return new Response("404 Page not found", {
|
||||
status: 404,
|
||||
});
|
||||
return ctx.renderNotFound();
|
||||
}
|
||||
const url = new URL(`../../../${entry.file}`, import.meta.url);
|
||||
const fileContent = await Deno.readTextFile(url);
|
||||
|
||||
Reference in New Issue
Block a user