feat(starter): add 404 page template (#1336)

This commit is contained in:
Marvin Hagemeister
2023-06-21 11:01:48 +02:00
committed by GitHub
parent 9b98e13e29
commit 87b15885aa
5 changed files with 74 additions and 19 deletions
+40 -1
View File
@@ -189,11 +189,50 @@ export default function Greet(props: PageProps) {
return <div>Hello {props.params.name}</div>;
}
`;
await Deno.mkdir(join(resolvedDirectory, "routes", "greet"), {
recursive: true,
});
await Deno.writeTextFile(
join(resolvedDirectory, "routes", "[name].tsx"),
join(resolvedDirectory, "routes", "greet", "[name].tsx"),
ROUTES_GREET_TSX,
);
// 404 page
const ROUTES_404_PAGE = `
import { Head } from "$fresh/runtime.ts";
export default function Error404() {
return (
<>
<Head>
<title>404 - Page not found</title>
</Head>
<div class="px-4 py-8 mx-auto bg-[#86efac]">
<div class="max-w-screen-md mx-auto flex flex-col items-center justify-center">
<img
class="my-6"
src="/logo.svg"
width="128"
height="128"
alt="the fresh logo: a sliced lemon dripping with juice"
/>
<h1 class="text-4xl font-bold">404 - Page not found</h1>
<p class="my-4">
The page you were looking for doesn't exist.
</p>
<a href="/" class="underline">Go back home</a>
</div>
</div>
</>
);
}
`;
await Deno.writeTextFile(
join(resolvedDirectory, "routes", "_404.tsx"),
ROUTES_404_PAGE,
);
const ROUTES_API_JOKE_TS = `import { HandlerContext } from "$fresh/server.ts";
// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/