feat(starter): add 404 page template (#1336)
This commit is contained in:
@@ -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/
|
||||
|
||||
Reference in New Issue
Block a user