dark mode at root fixes #75

This commit is contained in:
Ryan Stafford 2023-09-03 12:52:41 -04:00
parent 65c7d98b5a
commit 0508b95e24
2 changed files with 6 additions and 1 deletions

View file

@ -327,6 +327,11 @@ 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
if dark := getCookie(r, "Dark"); dark != "" {
data["Dark"] = dark != "0"
} else {
data["Dark"] = os.Getenv("DARK") != ""
}
tmpl, err := GetTemplate("root.html") tmpl, err := GetTemplate("root.html")
if err != nil { if err != nil {
fmt.Println("execute fail", err) fmt.Println("execute fail", err)

View file

@ -5,7 +5,7 @@
<link rel="stylesheet" href="/_/static/style.css?v=7"> <link rel="stylesheet" href="/_/static/style.css?v=7">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
</head> </head>
<body> <body{{ if .Dark }} class="dark"{{end}}>
<nav> <nav>
<div class="spacer"></div> <div class="spacer"></div>
<span class="title">{{ .Title }}</span> <span class="title">{{ .Title }}</span>