Hugo-theme-stack/layouts/page/search.json

26 lines
1.0 KiB
JSON
Raw Permalink Normal View History

2020-09-26 05:40:33 -04:00
{{- $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- $notHidden := where .Site.RegularPages "Params.hidden" "!=" true -}}
{{- $filtered := ($pages | intersect $notHidden) -}}
2020-09-26 05:40:33 -04:00
{{- $result := slice -}}
{{- range $filtered -}}
2020-09-26 16:50:23 -04:00
{{- $data := dict "title" .Title "date" .Date "permalink" .Permalink "content" (.Plain) -}}
2020-09-26 05:40:33 -04:00
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
{{- if $image.exists -}}
{{- $imagePermalink := "" -}}
{{- if and $image.resource (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
{{- $thumbnail := $image.resource.Fill "120x120" -}}
{{- $imagePermalink = (absURL $thumbnail.Permalink) -}}
{{- else -}}
{{- $imagePermalink = $image.permalink -}}
{{- end -}}
{{- $data = merge $data (dict "image" (absURL $imagePermalink)) -}}
{{- end -}}
2020-09-26 05:40:33 -04:00
{{- $result = $result | append $data -}}
{{- end -}}
{{ jsonify $result }}