diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 0cc44474..dd75243e 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,30 +1,7 @@ {{ partial "head/head.html" . }} - - {{ $template := "" }} - {{ if or (eq .Kind "404") (eq .Kind "page") (eq .Kind "home")}} - {{ $template = "single" }} - {{ else if or (eq .Kind "section") (eq .Kind "taxonomy") (eq .Kind "term") -}} - {{ $template = "list" }} - {{ end -}} - - {{ $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) -}} + {{- partial "head/body-class.html" -}} {{ if and .IsHome .Site.Params.alert }} {{ partial "header/alert.html" . }} diff --git a/layouts/partials/head/body-class.html b/layouts/partials/head/body-class.html new file mode 100644 index 00000000..c942ab7d --- /dev/null +++ b/layouts/partials/head/body-class.html @@ -0,0 +1,21 @@ +{{- $template := "" -}} +{{- if or (eq .Kind "404") (eq .Kind "page") (eq .Kind "home") -}} + {{ $template = "single" -}} +{{- else if or (eq .Kind "section") (eq .Kind "taxonomy") (eq .Kind "term") -}} + {{ $template = "list" -}} +{{- end -}} +{{- $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) -}} \ No newline at end of file