Skip to content

Commit 98cc790

Browse files
committed
tags: improve search index for tags matcornic#531
1 parent 4076eab commit 98cc790

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

layouts/_default/index.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
{{- partialCached "page-meta.hugo" . .RelPermalink }}
22
{{- $pages := slice }}
33
{{- range .Site.Pages }}
4-
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
5-
{{- $pages = $pages | append (dict "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) "title" .Title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
6-
{{- end }}
7-
{{- end }}
4+
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
5+
{{- $title := .Title }}
6+
{{- if eq .Kind "taxonomy" }}
7+
{{- $title = i18n .Data.Plural }}
8+
{{- if not $title }}
9+
{{- $title = .Data.Plural | humanize }}
10+
{{- end }}
11+
{{- else if eq .Kind "term" }}
12+
{{- $title = i18n .Data.Singular }}
13+
{{- if not $title }}
14+
{{- $title = .Data.Singular | humanize }}
15+
{{- end }}
16+
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (.Title | humanize) }}
17+
{{- end }}
18+
{{- $pages = $pages | append (dict "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) "title" $title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
19+
{{- end }}
20+
{{- end -}}
821
{{- $pages | jsonify (dict "indent" " ") }}

layouts/_default/index.search.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
{{- partialCached "page-meta.hugo" . .RelPermalink }}
22
{{- $pages := slice }}
33
{{- range .Site.Pages }}
4-
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
5-
{{- $pages = $pages | append (dict "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) "title" .Title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
6-
{{- end }}
4+
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
5+
{{- $title := .Title }}
6+
{{- if eq .Kind "taxonomy" }}
7+
{{- $title = i18n .Data.Plural }}
8+
{{- if not $title }}
9+
{{- $title = .Data.Plural | humanize }}
10+
{{- end }}
11+
{{- else if eq .Kind "term" }}
12+
{{- $title = i18n .Data.Singular }}
13+
{{- if not $title }}
14+
{{- $title = .Data.Singular | humanize }}
15+
{{- end }}
16+
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (.Title | humanize) }}
17+
{{- end }}
18+
{{- $pages = $pages | append (dict "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) "title" $title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
19+
{{- end }}
720
{{- end -}}
821
var relearn_search_index = {{ $pages | jsonify (dict "indent" " ") }}

0 commit comments

Comments
 (0)