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:
parent
db28ce75d1
commit
6945b0de20
@ -41,7 +41,8 @@
|
||||
}
|
||||
{{- 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 }}
|
||||
|
||||
{{- with .Params.description -}}
|
||||
|
Loading…
Reference in New Issue
Block a user