-
Notifications
You must be signed in to change notification settings - Fork 43
/
list.searchindex.json
48 lines (39 loc) · 1.9 KB
/
list.searchindex.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{{- $allSections := slice -}}
{{- range site.Home.Sections -}}
{{- $allSections = $allSections | append .Section -}}
{{- end -}}
{{- $include_all_sections := site.Params.search.include_all_sections -}}
{{- $search_sections := $allSections -}}
{{- if not $include_all_sections -}}
{{- $search_sections = site.Params.search.include_sections | default site.Params.mainSections -}}
{{- end -}}
{{- $totalPagesLength := len (where site.RegularPages "Section" "in" $search_sections) -}}
[{{- range $i, $e := (where site.RegularPages "Section" "in" $search_sections) -}}
{{- if not .Params.ignoreSearch -}}
{{- $date:= time.Format ":date_long" .PublishDate -}}
{{- if .Params.image -}}
{{- $.Scratch.Set "image" (partial "searchImage" (dict "Src" .Params.image "Size" "420x" "Command" "Resize")) -}}
{{- $.Scratch.Set "imageSM" (partial "searchImage" (dict "Src" .Params.image "Size" "100x100" "Command" "Fill")) -}}
{{- else if .Params.images -}}
{{- range first 1 .Params.images -}}
{{- $.Scratch.Set "image" (partial "searchImage" (dict "Src" . "Size" "420x" "Command" "Resize")) -}}
{{- $.Scratch.Set "imageSM" (partial "searchImage" (dict "Src" . "Size" "100x100" "Command" "Fill")) -}}
{{- end -}}
{{- end -}}
{{- $image:= $.Scratch.Get "image" -}}
{{- $imageSM:= $.Scratch.Get "imageSM" -}}
{
"section": "{{.Section | humanize}}",
"slug": "{{- .RelPermalink -}}",
"title": "{{- htmlEscape .Title -}}",
"description": "{{- htmlEscape .Description}}",
"date": "{{- $date -}}",
"image": {{$image | jsonify}},
"imageSM": {{$imageSM | jsonify}},
"searchKeyword": "{{- htmlEscape .Params.search_keyword -}}",
"categories": "{{- if .Params.categories -}}{{- delimit .Params.categories `, ` -}}{{- end -}}",
"tags": "{{- if .Params.tags -}}{{- delimit .Params.tags `, ` -}}{{- end -}}",
"content": {{- $e.Plain | jsonify -}}
}{{- if ne $i (sub $totalPagesLength 1) -}},{{- end -}}
{{- end -}}
{{- end -}}]