This commit is contained in:
Ryan Stafford 2024-05-11 14:48:49 -04:00
parent 17e4bc76b9
commit 1fe8e5a5b5

View file

@ -365,18 +365,22 @@ func Render(w http.ResponseWriter, templateName string, state State) {
func GetRoot(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { func GetRoot(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
data := make(map[string]any) data := make(map[string]any)
data["Title"] = r.Host data["Title"] = r.Host
d := true
if dark := getCookie(r, "Dark"); dark != "" { if dark := getCookie(r, "Dark"); dark != "" {
data["Dark"] = dark != "0" d = dark != "0"
data["Dark"] = &d
} else if dark := os.Getenv("DARK"); dark != "" { } else if dark := os.Getenv("DARK"); dark != "" {
data["Dark"] = true data["Dark"] = &d
} }
tmpl, err := GetTemplate("root.html") tmpl, err := GetTemplate("root.html")
if err != nil { if err != nil {
fmt.Println("execute fail", err) fmt.Println("template fail", err)
w.Write([]byte("500 - Server Error")) w.Write([]byte("500 - Server Error"))
return return
} }
tmpl.Execute(w, data) if err = tmpl.Execute(w, data); err != nil {
fmt.Println("execute fail", err)
}
} }
type NodeSoftware struct { type NodeSoftware struct {