Fix index.json encoding

This commit is contained in:
Helder Pereira 2021-08-31 10:33:22 +01:00
parent 9bc3f4e416
commit c75e5532f9
2 changed files with 9 additions and 12 deletions

View file

@ -23,6 +23,8 @@ Note that some of these parameters are explained in details in other sections of
showVisitedLinks = false
# Disable search function. It will hide search bar
disableSearch = false
# Make hidden pages searchable
searchHiddenPages = false
# Javascript and CSS cache are automatically busted when new version of site is generated.
# Set this to true to disable this behavior (some proxies don't handle well this optimization)
disableAssetsBusting = false

View file

@ -1,12 +1,7 @@
[{{ range $index, $page := .Site.Pages }}
{{- if ne $page.Type "json" -}}
{{- if and $index (gt $index 0) -}},{{- end }}
{
"uri": "{{ $page.RelPermalink }}",
"title": "{{ htmlEscape $page.Title}}",
"tags": [{{ range $tindex, $tag := $page.Params.tags }}{{ if $tindex }}, {{ end }}"{{ $tag| htmlEscape }}"{{ end }}],
"description": "{{ htmlEscape .Description}}",
"content": {{$page.Plain | jsonify}}
}
{{- end -}}
{{- end -}}]
{{- $pages := slice }}
{{- range .Site.Pages }}
{{- if or .Site.Params.searchHiddenPages (and (ne .Params.hidden true) (ne .Title "")) }}
{{- $pages = $pages | append (dict "uri" .RelPermalink "title" .Title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
{{- end }}
{{- end }}
{{- $pages | jsonify (dict "indent" " ") }}