add:not found page

This commit is contained in:
kokopi-dev
2026-03-09 01:19:27 +09:00
parent cd593219f7
commit c5c49f07e9
4 changed files with 33 additions and 0 deletions

13
handlers/error.go Normal file
View File

@@ -0,0 +1,13 @@
package handlers
import (
"net/http"
"personal-site/pages"
"github.com/gin-gonic/gin"
)
func NotFoundHandler(c *gin.Context) {
c.Status(http.StatusNotFound)
pages.ErrorPage().Render(c.Request.Context(), c.Writer)
}

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"os"
"os/signal"
"personal-site/handlers"
"personal-site/pages"
"syscall"
"time"
@@ -21,6 +22,7 @@ func setupRoutesAndMiddleware() *gin.Engine {
page := pages.Index()
page.Render(c.Request.Context(), c.Writer)
})
r.NoRoute(handlers.NotFoundHandler)
return r
}

14
pages/error.templ Normal file
View File

@@ -0,0 +1,14 @@
package pages
import "personal-site/components"
import "personal-site/constants"
templ ErrorPage() {
{{ params := constants.NewLayoutParams("Not Found") }}
@components.MainLayout(params) {
<div class="mx-auto flex flex-col gap-4 text-center">
<h2>page not found</h2>
<a href="/">Go Home</a>
</div>
}
}

View File

@@ -27,6 +27,10 @@
}
@layer base {
body {
font-family: var(--font-sans);
-webkit-font-smoothing: antialiased;
}
@keyframes fadeUp {
from {
opacity: 0;