Open garz75 opened 2 years ago
When using a yaml front matter with a multiline description that uses a Block Style Indicator (> or |)
--- title: Simple title chapter: false weight: 40 description: | This is the beginning of a multiline description... ---
The JSON file generated by the index.json template is invalid: The description contains a \n at the end:
\n
[ { "uri": "/example.html", "title": "Simple title", "tags": [], "description": "This is the beginning of a multiline description... ", "content": "blah" } ]
My attempt at fixing this issue is to trim the extra\n in the template:
diff --git a/layouts/index.json b/layouts/index.json index 367f3b3..011b7c8 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -5,7 +5,7 @@ "uri": "{{ $page.Permalink }}", "title": "{{ htmlEscape $page.Title}}", "tags": [{{ range $tindex, $tag := $page.Params.tags }}{{ if $tindex }}, {{ end }}"{{ $tag| htmlEscape }}"{{ end }}], - "description": "{{ htmlEscape .Description}}", + "description": "{{ trim .Description "\n" | htmlEscape }}", "content": {{$page.Plain | jsonify}} } {{- end -}}
This seems to work for me but I am very new at Hugo templating... Am I on the right track ? Is there a way to fix this in a better way ?
Thank you in Advance.
Seems to work in the Relearn fork.
When using a yaml front matter with a multiline description that uses a Block Style Indicator (> or |)
The JSON file generated by the index.json template is invalid: The description contains a
\n
at the end:My attempt at fixing this issue is to trim the extra
\n
in the template:This seems to work for me but I am very new at Hugo templating... Am I on the right track ? Is there a way to fix this in a better way ?
Thank you in Advance.