Skip to content

Commit

Permalink
Fix a offline search result when excerpt contains HTML entities
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed May 23, 2020
1 parent 4e0c7e8 commit bac04df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion assets/json/offline-search-index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- $.Scratch.Add "offline-search-index" slice -}}
{{- range where .Site.AllPages ".Params.exclude_search" "!=" true -}}
{{- $.Scratch.Add "offline-search-index" (dict "title" (.Title | htmlUnescape) "ref" .RelPermalink "body" (.Plain | htmlUnescape) "excerpt" (.Plain | htmlUnescape | truncate (.Site.Params.offlineSearchSummaryLength | default 70))) -}}
{{/* We have to apply `htmlUnescape` again after `truncate` because `truncate` applies `html.EscapeString` if the argument is not HTML. */}}
{{- $.Scratch.Add "offline-search-index" (dict "title" .Title "ref" .RelPermalink "body" (.Plain | htmlUnescape) "excerpt" (.Plain | htmlUnescape | truncate (.Site.Params.offlineSearchSummaryLength | default 70) | htmlUnescape)) -}}
{{- end -}}
{{- $.Scratch.Get "offline-search-index" | jsonify -}}

0 comments on commit bac04df

Please sign in to comment.