Explore a new approach to clean up the implementation of an AppShell and individual pages. Will likely retire htmx for a lightweight custom page router.
23 lines
589 B
TypeScript
23 lines
589 B
TypeScript
import { Html } from "@elysiajs/html";
|
|
import { Elysia, NotFoundError } from "elysia";
|
|
|
|
import { Home } from "../frontend/home";
|
|
import { Blog } from "../frontend/blog";
|
|
import { NotFound } from "../frontend/not-found";
|
|
|
|
|
|
export const app = new Elysia()
|
|
.onError(({ error }) => {
|
|
if(error instanceof NotFoundError) {
|
|
return <NotFound />;
|
|
}
|
|
return error;
|
|
})
|
|
.get("/", () => { return <Home /> })
|
|
.get("/:path", ({ path }) => {
|
|
if(path === "/blog") {
|
|
return <Blog />;
|
|
}
|
|
throw new NotFoundError();
|
|
})
|