My theme has a search bar involving json and some javascript.
My titles and sections’ titles often have ponctuations in them. While the menus can render them well, and I can plainify markup, but I don’t know how to automatically escape ponctuation in the json part then unescape it to display it correctly.
I have no experience whatsoever with json, can you help me what is basically improving on this theme ? It probably comes down to a few words.
---
Title : "Man's regeneration"
Error message:
MINIFY: failed to transform "en.search-data.json" (application/json): JSON parse error: unexpected character 'M' on line 6 and column 16 6: "section": Man’s demise, ^
search-data.json
[
{{- $pages := where .Site.Pages "Kind" "in" (slice "page" "section") -}}
{{- $pages = where $pages "Params.booksearchexclude" "!=" true -}}
{{ range $index, $page := $pages }}
{{ if gt $index 0}},{{end}} {
"id": {{ $index }},
"href": "{{ $page.RelPermalink }}",
"title": {{ (partial "docs/title" $page)|plainify|jsonify }},
"section": {{ markdownify (partial "docs/title" $page.Parent) }},
"content": {{ $page.Plain | jsonify }}
}
{{- end -}}
]
Here’s the sample
Thanks !