add:not found page
This commit is contained in:
13
handlers/error.go
Normal file
13
handlers/error.go
Normal 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)
|
||||
}
|
||||
2
main.go
2
main.go
@@ -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
14
pages/error.templ
Normal 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>
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,10 @@
|
||||
}
|
||||
|
||||
@layer base {
|
||||
body {
|
||||
font-family: var(--font-sans);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
@keyframes fadeUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
|
||||
Reference in New Issue
Block a user