1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-12-19 00:52:19 +01:00

layouts/_default/single.html: Improve Schema.org keywords

Use delimit function over a union of Categories and Tags. This is
much easier to read, results in correct delimiting with no trailing
comma, and works even if one of the slices is nil.
This commit is contained in:
Alan Orth 2017-07-07 16:25:56 +03:00
parent db28ce75d1
commit 6945b0de20
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -41,7 +41,8 @@
} }
{{- if or (.Params.categories) (.Params.tags) -}} {{- if or (.Params.categories) (.Params.tags) -}}
, ,
"keywords": "{{ with .Params.categories }}{{ range $i, $e := . }}{{ if $i }},{{ end }}{{ $e }}{{ end }},{{ end }}{{ with .Params.tags }}{{ range $i, $e := . }}{{ if $i }},{{ end }}{{ $e }}{{ end }}{{ end }}" {{- /* delimit keywords by comma, even if one of .Params.categories or Params.tags is nil */ -}}
"keywords": "{{ delimit (union .Params.categories .Params.tags) ", " }}"
{{- end }} {{- end }}
{{- with .Params.description -}} {{- with .Params.description -}}