Added a page-specific CSS class on <body>

main
Antonio De Lucreziis 3 years ago
parent 8a5e1a54c0
commit 1f099d4d53

@ -2,6 +2,7 @@ package main
import (
"io"
"strings"
"text/template"
"github.com/phc-dm/server-poisson/config"
@ -41,6 +42,10 @@ func (t *TemplateRenderer) Render(w io.Writer, name string, data util.H) error {
newData := util.H{}
newData.Apply(data)
newData["Page"] = util.H{
// Used to inject a page specific class on <body>
"Name": strings.TrimSuffix(name, ".html"),
}
newData["Config"] = config.Object()
return tmpl.ExecuteTemplate(w, "base", newData)

@ -61,7 +61,7 @@
<link rel="stylesheet" href="/assets/theme-dark.css">
</head>
<body>
<body {{ if .Page.Name }}class="page-{{ .Page.Name }}"{{ end }}>
<nav>
<!-- Site -->
<div class="nav-logo">

Loading…
Cancel
Save