summaryrefslogtreecommitdiff
path: root/internal/router/root.go
diff options
from:
to:
context:
space:
mode:
authorGravatar Saya Andy <145215889+SayaAndy@users.noreply.github.com> 2025-08-18 19:28:18 +0700
committerGravatar GitHub <noreply@github.com> 2025-08-18 19:28:18 +0700
commit6401cf603f598a8008c69a14fe58f460009180a7 (patch)
treee275408d111e0fd98f46826ca6cabba6aafdd763 /internal/router/root.go
parent188d24d6cb7a1d753898b340359e3fcfaf426433 (diff)
parentf3b5c8136217fd57f7ae948a153f3510558a139d (diff)
downloadweb-0.6.0.tar.gz
web-0.6.0.zip
v0.6.0v0.6.0
- feat: add map page - feat: use webp of various sizes (320/560/800/1200/1600w) as thumbnails - feat: fixate gallery divs to viewport measures - feat: make thumbnails square - feat: remove recreating gallery on window resize - refactor: replace gap with margins - refactor: more line height in gallery captions - refactor: have routes in separate files
Diffstat (limited to 'internal/router/root.go')
-rw-r--r--internal/router/root.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/router/root.go b/internal/router/root.go
new file mode 100644
index 0000000..f5be6cb
--- /dev/null
+++ b/internal/router/root.go
@@ -0,0 +1,24 @@
+package router
+
+import (
+ "log/slog"
+
+ "github.com/SayaAndy/saya-today-web/config"
+ "github.com/SayaAndy/saya-today-web/internal/templatemanager"
+ "github.com/gofiber/fiber/v2"
+)
+
+func Root(tm *templatemanager.TemplateManager, localeCfg []config.AvailableLanguageConfig) func(c *fiber.Ctx) error {
+ return func(c *fiber.Ctx) error {
+ content, err := tm.Render("index", fiber.Map{
+ "AvailableLanguages": localeCfg,
+ })
+ if err != nil {
+ slog.Warn("failed to generate page", slog.String("page", "/"), slog.String("error", err.Error()))
+ c.Set(fiber.HeaderContentType, fiber.MIMETextPlainCharsetUTF8)
+ return c.Status(fiber.ErrInternalServerError.Code).SendString("failed to generate page")
+ }
+
+ return c.Type("html").Send(content)
+ }
+}