From 44a2a26ffc12552bee93e80d4097cf39d547e40f Mon Sep 17 00:00:00 2001
From: paku <paku@skyizwhite.dev>
Date: Sat, 24 Feb 2024 20:31:06 +0900
Subject: [PATCH] Add not-found page

---
 src/app.lisp                  |  7 +++++++
 src/components/not-found.lisp | 14 ++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 src/components/not-found.lisp

diff --git a/src/app.lisp b/src/app.lisp
index 3985415..98a262f 100644
--- a/src/app.lisp
+++ b/src/app.lisp
@@ -2,6 +2,8 @@
   (:use #:cl)
   (:local-nicknames (#:jg #:jingle))
   (:local-nicknames (#:fbr #:ningle-fbr))
+  (:local-nicknames (#:pi #:piccolo))
+  (:local-nicknames (#:cmp #:hp/components/*))
   (:import-from #:lack)
   (:export #:*app*
            #:update-routes))
@@ -9,6 +11,11 @@
 
 (defparameter *raw-app* (jg:make-app))
 
+(defmethod jg:not-found ((app jg:app))
+  (jg:with-html-response
+    (jg:set-response-status 404)
+    (pi:element-string (cmp:not-found-page))))
+
 (defun update-routes ()
   (fbr:enable-file-based-routing *raw-app*
                                  :dir "src/routes"
diff --git a/src/components/not-found.lisp b/src/components/not-found.lisp
new file mode 100644
index 0000000..95836bb
--- /dev/null
+++ b/src/components/not-found.lisp
@@ -0,0 +1,14 @@
+(uiop:define-package #:hp/components/not-found
+  (:use #:cl)
+  (:local-nicknames (#:pi #:piccolo))
+  (:import-from #:hp/components/layout
+                #:layout)
+  (:export #:not-found-page))
+(in-package #:hp/components/not-found)
+
+(pi:define-element not-found-page ()
+  (pi:h
+    (layout
+      (section :class "h-full flex justify-center items-center"
+        (h1 :class "text-error text-4xl"
+          "404 Not Found")))))