Fix invalid json when page has no content or description.

This commit is contained in:
Fredrik Jonsson 2023-01-17 08:43:43 +01:00
commit 1bd584da5f

View file

@ -7,7 +7,9 @@
"datePublished": {{ .Date.Format "2006-01-02T15:04:05Z07:00" }},
"dateModified": {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }},
"url" : {{ .Permalink }},
"description": {{ with (.Description | default (replaceRE "\n" " " (.Plain | truncate 170))) }}{{ . }}{{ end }},
{{ with (.Description | default (replaceRE "\n" " " (.Plain | truncate 170))) -}}
"description": {{ . }},
{{ end -}}
{{ with .Params.tags -}}
"keywords": {{ . }},
{{ end -}}