36 lines
1.4 KiB
JSON
36 lines
1.4 KiB
JSON
{{- $len := sub (len (.Pages.GroupBy "Section")) 1 -}}
|
|
[{{- range $item, $el := .Pages.GroupBy "Section" -}}
|
|
{{- range $i, $e := .Pages -}}
|
|
{{- if and (not .Params.ignoreSearch) (ne $e.Type "json") -}}
|
|
{
|
|
"section": "",
|
|
"url": "{{ $e.Permalink }}",
|
|
"title": "{{ with $e.Params.bannertext }}{{htmlEscape .}}{{else}}{{htmlEscape $e.Title}}{{end}}",
|
|
"description": "{{ htmlEscape .Description}}",
|
|
"searchKeyword": "{{ htmlEscape .Params.searchKeyword}}",
|
|
"content": {{$e.Plain | jsonify}}
|
|
},
|
|
{{- end -}}
|
|
|
|
{{- if .Section -}}
|
|
{{- $section := (where site.Pages "Section" .Section) | intersect (where site.Pages ".Title" "!=" .Title) -}}
|
|
{{- $sectionLen := len (where site.Pages "Section" .Section) -}}
|
|
{{- $sectionLenTotal := sub $sectionLen 2 -}}
|
|
|
|
{{- range $index, $page := $section -}}
|
|
{{- if and (not .Params.ignoreSearch) (ne $page.Type "json") -}}
|
|
{
|
|
"section": "{{$page.Section | humanize}}",
|
|
"url": "{{ $page.Permalink }}",
|
|
"title": "{{ with $page.Params.bannertext }}{{htmlEscape .}}{{else}}{{htmlEscape $page.Title}}{{end}}",
|
|
"description": "{{ htmlEscape .Description}}",
|
|
"searchKeyword": "{{ htmlEscape .Params.searchKeyword}}",
|
|
"content": {{$page.Plain | jsonify}}
|
|
}{{- if eq $item $len -}}{{- if ne $index $sectionLenTotal -}},{{- end -}}{{- else -}},{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
{{- end -}}] |