diff --git a/wowchemy/layouts/publication/single.html b/wowchemy/layouts/publication/single.html index 3e2d43a9..4af44866 100644 --- a/wowchemy/layouts/publication/single.html +++ b/wowchemy/layouts/publication/single.html @@ -1,4 +1,15 @@ {{- define "main" -}} +{{ $pub_types := partial "functions/get_pub_types" $ }} +{{ $pub_type_param := .Params.publication_types | default (slice 0) }} + +{{/* Convert string in form `"0"` to int (`0`) */}} +{{ $pub_type := (int (index $pub_type_param 0)) | default 0 }} + +{{/* Validate Pub Type if defined */}} +{{ if gt $pub_type (sub (len $pub_types) 1) }} + {{ warnf "Unknown publication type in %s" .Path }} + {{ $pub_type = 0 }} +{{ end }}
@@ -11,19 +22,17 @@

{{ .Params.abstract | markdownify }}

{{ end }} - {{ if and (.Params.publication_types) (ne (index .Params.publication_types 0) "0") }} + {{/* If the type is Uncategorized, hide the type. */}} + {{ if ne $pub_type 0 }}
{{ i18n "publication_type" }}
- {{ $pub_types := partial "functions/get_pub_types" $ }} - {{ range $index, $pubtype := .Params.publication_types }} - - {{ index $pub_types (int .) }} + + {{ index $pub_types $pub_type }} - {{ end }}