Added a page-specific CSS class on <body>
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/phc-dm/server-poisson/config"
|
"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 := util.H{}
|
||||||
newData.Apply(data)
|
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()
|
newData["Config"] = config.Object()
|
||||||
|
|
||||||
return tmpl.ExecuteTemplate(w, "base", newData)
|
return tmpl.ExecuteTemplate(w, "base", newData)
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@
|
|||||||
<link rel="stylesheet" href="/assets/theme-dark.css">
|
<link rel="stylesheet" href="/assets/theme-dark.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body {{ if .Page.Name }}class="page-{{ .Page.Name }}"{{ end }}>
|
||||||
<nav>
|
<nav>
|
||||||
<!-- Site -->
|
<!-- Site -->
|
||||||
<div class="nav-logo">
|
<div class="nav-logo">
|
||||||
|
|||||||
Reference in New Issue
Block a user