From 1fe8e5a5b5758485b234d5d29223f923452caef5 Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Sat, 11 May 2024 14:48:49 -0400 Subject: [PATCH] root ref --- routes.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/routes.go b/routes.go index 159d683..480cd89 100644 --- a/routes.go +++ b/routes.go @@ -365,18 +365,22 @@ func Render(w http.ResponseWriter, templateName string, state State) { func GetRoot(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { data := make(map[string]any) data["Title"] = r.Host + d := true if dark := getCookie(r, "Dark"); dark != "" { - data["Dark"] = dark != "0" + d = dark != "0" + data["Dark"] = &d } else if dark := os.Getenv("DARK"); dark != "" { - data["Dark"] = true + data["Dark"] = &d } tmpl, err := GetTemplate("root.html") if err != nil { - fmt.Println("execute fail", err) + fmt.Println("template fail", err) w.Write([]byte("500 - Server Error")) return } - tmpl.Execute(w, data) + if err = tmpl.Execute(w, data); err != nil { + fmt.Println("execute fail", err) + } } type NodeSoftware struct {