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

20 lines
803 B
JSON
Raw 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) -}}
{{- $result := slice -}}
{{- range $filtered -}}
{{- $data := dict "title" .Title "date" .Date "permalink" .Permalink "content" (htmlUnescape .Plain) -}}
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
{{- if and $image.exists $image.resource -}}
{{- $thumbnail := $image.resource.Fill "120x120" -}}
{{- $image := dict "image" (absURL $thumbnail.Permalink) -}}
{{- $data = merge $data $image -}}
{{ end }}
{{- $result = $result | append $data -}}
{{- end -}}
{{ jsonify $result }}