From 18d151e0cf1bf36aa4b261d91c37fe5c601fc96e Mon Sep 17 00:00:00 2001 From: valxntine Date: Sun, 17 Aug 2025 14:32:33 +0000 Subject: [PATCH] move to embedded css, update hx state for spinner bug --- main.go | 8 ++++++-- templates/layout.templ | 22 +++++++++++++++------- templates/layout_templ.go | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 4d78fdf..f1b1f70 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "embed" "fmt" "log" "net/http" @@ -11,11 +12,14 @@ import ( "git.valxntine.dev/valxntine/blog/templates" ) +//go:embed static/* +var staticFS embed.FS + func main() { mux := http.NewServeMux() - fs := http.FileServer(http.Dir("./static/")) - mux.Handle("/static/", http.StripPrefix("/static/", fs)) + staticHandler := http.FileServer(http.FS(staticFS)) + mux.Handle("/static/", staticHandler) mux.HandleFunc("/", handleHome) mux.HandleFunc("/posts/", handlePost) diff --git a/templates/layout.templ b/templates/layout.templ index 8f72790..715e6d3 100644 --- a/templates/layout.templ +++ b/templates/layout.templ @@ -13,13 +13,21 @@ templ Layout(title string) { { children... } diff --git a/templates/layout_templ.go b/templates/layout_templ.go index e96aeb1..ac11c9b 100644 --- a/templates/layout_templ.go +++ b/templates/layout_templ.go @@ -50,7 +50,7 @@ func Layout(title string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }