From 0508b95e24574f730f64513359a417bdb7de0158 Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Sun, 3 Sep 2023 12:52:41 -0400 Subject: [PATCH] dark mode at root fixes #75 --- routes.go | 5 +++++ templates/root.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/routes.go b/routes.go index 032582a..19aa8b6 100644 --- a/routes.go +++ b/routes.go @@ -327,6 +327,11 @@ 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 + if dark := getCookie(r, "Dark"); dark != "" { + data["Dark"] = dark != "0" + } else { + data["Dark"] = os.Getenv("DARK") != "" + } tmpl, err := GetTemplate("root.html") if err != nil { fmt.Println("execute fail", err) diff --git a/templates/root.html b/templates/root.html index c828627..d78110a 100644 --- a/templates/root.html +++ b/templates/root.html @@ -5,7 +5,7 @@ - +