Skip to content

Commit bb46f07

Browse files
committed
[feat]: improved 404 routing flow
1 parent 47dfead commit bb46f07

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

apps/www/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "www",
3-
"version": "1.14.8",
3+
"version": "1.14.9",
44
"module": "src/index.js",
55
"scripts": {
66
"dev": "bun run --hot src/index.tsx",

apps/www/src/controllers/404.controller.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

apps/www/src/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { AppContext, serverConfig } from "$config/server";
2-
import { notFoundController } from "$controllers/404.controller";
32
import { componentsController } from "$controllers/components/*";
43
import { coreController } from "$controllers/core/*";
54
import { homeController } from "$controllers/home.controller";
65
import { useCasesController } from "$controllers/usecases/*";
76
import { htmxMiddleware } from "$middlewares/htmx.middleware";
7+
import { NotFoundPage } from "$pages/404.page";
88
import { Hono } from "hono";
99
import { serveStatic } from "hono/bun";
1010

@@ -25,8 +25,15 @@ app
2525
.route("/core", coreController)
2626
.route("/components", componentsController)
2727
.route("/usecases", useCasesController)
28-
.route("/404-not-found", notFoundController)
29-
.notFound(ctx => ctx.redirect("/404-not-found"));
28+
.notFound(ctx => {
29+
if (ctx.var.isHTMX) {
30+
ctx.header("HX-Reswap", "outerHTML");
31+
ctx.header("HX-Retarget", "#main-content");
32+
}
33+
return ctx.html(
34+
<NotFoundPage seo={{ title: "Page not found" }} {...ctx.var} />
35+
);
36+
});
3037

3138
export default {
3239
port: serverConfig.port,

0 commit comments

Comments
 (0)