From b0dc0a7a02bab63bb1ad475472a90f63712862eb Mon Sep 17 00:00:00 2001 From: sean-pwd Date: Sun, 29 Aug 2021 01:52:05 +1000 Subject: [PATCH] fix: update body classes --- layouts/_default/baseof.html | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 44936902..0cc44474 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,17 +1,30 @@ {{ partial "head/head.html" . }} + {{ $template := "" }} - {{ $type := "default" }} - {{ if ne .Type "page" }} - {{ $type = .Type }} - {{ end }} - {{ if or (eq .Kind "404") (eq .Kind "page") }} + {{ if or (eq .Kind "404") (eq .Kind "page") (eq .Kind "home")}} {{ $template = "single" }} - {{ else if or (eq .Kind "section") (eq .Kind "taxonomy") (eq .Kind "taxonomyTerm") -}} + {{ else if or (eq .Kind "section") (eq .Kind "taxonomy") (eq .Kind "term") -}} {{ $template = "list" }} {{ end -}} - {{ .Scratch.Set "class" (slice .Kind $template $type) -}} + + {{ $name := "" }} + {{ if eq .Kind "taxonomy" }} + {{ $name = printf "taxonomy %s" .Data.Plural }} + {{ else if eq .Kind "term" }} + {{ $name = printf "term %s" .Section}} + {{ else if .Section }} + {{ $name = printf "section %s" .Section }} + {{ else if eq .Kind "page" }} + {{ $name = .File.ContentBaseName }} + {{ else if eq .Kind "home" }} + {{ $name = "home" }} + {{ else if eq .Kind "404" }} + {{ $name = "error404" }} + {{ end }} + + {{ .Scratch.Set "class" (slice $template $name) -}} {{ if and .IsHome .Site.Params.alert }} {{ partial "header/alert.html" . }}