mirror of https://github.com/onweru/compose.git

weru
2 days ago 66c6a4fede9158419277b86634a8ecf00d6bbb3d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{{- $index := newScratch -}}
{{- $index.Add "index" slice -}}
{{- $searchableExtras := site.Params.otherSearchableFields -}}
{{- range site.Pages -}}
  {{- $params := .Params -}}
  {{- if ne .Type "search" -}}
    {{- $searchEntry := dict "title" .Title "body" .Plain "link" .Permalink "section" .Section -}}
    {{- range $i, $value := $searchableExtras -}}
      {{- $extraFieldValue := index $params $value -}}
      {{- $extraFieldValues := dict -}}
      {{- with $extraFieldValue -}}
        {{- $v := . -}}
        {{- if reflect.IsSlice . -}}
          {{- $v = delimit . "," -}}
        {{- end -}}
        {{- $extraFieldValues = dict (lower $value) $v -}}
      {{- end -}}
      {{- $searchEntry = merge $searchEntry $extraFieldValues -}}
    {{- end -}}
    {{- $index.Add "index" $searchEntry -}}
  {{- end -}}
{{- end -}}
{{- jsonify (uniq ($index.Get "index")) -}}