* 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
@@ -44,20 +44,18 @@ export default function DefaultErrorPage(props: ErrorPageProps) {
|
|||||||
>
|
>
|
||||||
An error occured during route handling or page rendering.
|
An error occured during route handling or page rendering.
|
||||||
</p>
|
</p>
|
||||||
{message && (
|
{message && <pre
|
||||||
<pre
|
style={{
|
||||||
style={{
|
margin: 0,
|
||||||
margin: 0,
|
fontSize: "12pt",
|
||||||
fontSize: "12pt",
|
overflowY: "auto",
|
||||||
overflowY: "auto",
|
padding: 16,
|
||||||
padding: 16,
|
paddingTop: 0,
|
||||||
paddingTop: 0,
|
fontFamily: "monospace",
|
||||||
fontFamily: "monospace",
|
}}
|
||||||
}}
|
>
|
||||||
>
|
|
||||||
{message}
|
{message}
|
||||||
</pre>
|
</pre>}
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+12
-8
@@ -2,20 +2,24 @@
|
|||||||
// This file SHOULD be checked into source version control.
|
// This file SHOULD be checked into source version control.
|
||||||
// This file is automatically updated during development when running `dev.ts`.
|
// This file is automatically updated during development when running `dev.ts`.
|
||||||
|
|
||||||
import * as $0 from "./routes/docs/[...slug].tsx";
|
import * as $0 from "./routes/_404.tsx";
|
||||||
import * as $1 from "./routes/gfm.css.ts";
|
import * as $1 from "./routes/_500.tsx";
|
||||||
import * as $2 from "./routes/index.tsx";
|
import * as $2 from "./routes/docs/[...slug].tsx";
|
||||||
import * as $3 from "./routes/raw.ts";
|
import * as $3 from "./routes/gfm.css.ts";
|
||||||
|
import * as $4 from "./routes/index.tsx";
|
||||||
|
import * as $5 from "./routes/raw.ts";
|
||||||
import * as $$0 from "./islands/CopyArea.tsx";
|
import * as $$0 from "./islands/CopyArea.tsx";
|
||||||
import * as $$1 from "./islands/Counter.tsx";
|
import * as $$1 from "./islands/Counter.tsx";
|
||||||
import * as $$2 from "./islands/LemonDrop.tsx";
|
import * as $$2 from "./islands/LemonDrop.tsx";
|
||||||
|
|
||||||
const manifest = {
|
const manifest = {
|
||||||
routes: {
|
routes: {
|
||||||
"./routes/docs/[...slug].tsx": $0,
|
"./routes/_404.tsx": $0,
|
||||||
"./routes/gfm.css.ts": $1,
|
"./routes/_500.tsx": $1,
|
||||||
"./routes/index.tsx": $2,
|
"./routes/docs/[...slug].tsx": $2,
|
||||||
"./routes/raw.ts": $3,
|
"./routes/gfm.css.ts": $3,
|
||||||
|
"./routes/index.tsx": $4,
|
||||||
|
"./routes/raw.ts": $5,
|
||||||
},
|
},
|
||||||
islands: {
|
islands: {
|
||||||
"./islands/CopyArea.tsx": $$0,
|
"./islands/CopyArea.tsx": $$0,
|
||||||
|
|||||||
@@ -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];
|
const entry = TABLE_OF_CONTENTS[slug];
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return new Response("404 Page not found", {
|
return ctx.renderNotFound();
|
||||||
status: 404,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
const url = new URL(`../../../${entry.file}`, import.meta.url);
|
const url = new URL(`../../../${entry.file}`, import.meta.url);
|
||||||
const fileContent = await Deno.readTextFile(url);
|
const fileContent = await Deno.readTextFile(url);
|
||||||
|
|||||||
Reference in New Issue
Block a user