offline-search-index.json 959 B

123456789101112131415161718
  1. {{- $.Scratch.Add "offline-search-index" slice -}}
  2. {{- range where .Site.AllPages ".Params.exclude_search" "!=" true -}}
  3. {{- /* We have to apply `htmlUnescape` again after `truncate` because `truncate` applies `html.EscapeString` if the argument is not HTML. */ -}}
  4. {{- /* Individual taxonomies can be added in the next line by add '"taxonomy-name" (.Params.taxonomy-name | default "")' to the dict (as seen for categories and tags). */ -}}
  5. {{- $.Scratch.Add
  6. "offline-search-index"
  7. (dict
  8. "ref" .RelPermalink
  9. "title" .Title
  10. "categories" (.Params.categories | default "")
  11. "tags" (.Params.tags | default "")
  12. "description" (.Description | default "")
  13. "body" (.Plain | htmlUnescape)
  14. "excerpt" ((.Description | default .Plain) | htmlUnescape | truncate (.Site.Params.offlineSearchSummaryLength | default 70) | htmlUnescape)
  15. )
  16. -}}
  17. {{- end -}}
  18. {{- $.Scratch.Get "offline-search-index" | jsonify -}}