search.json 1.0 KB

1234567891011121314151617181920212223242526
  1. {{- $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
  2. {{- $notHidden := where .Site.RegularPages "Params.hidden" "!=" true -}}
  3. {{- $filtered := ($pages | intersect $notHidden) -}}
  4. {{- $result := slice -}}
  5. {{- range $filtered -}}
  6. {{- $data := dict "title" .Title "date" .Date "permalink" .Permalink "content" (.Plain) -}}
  7. {{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
  8. {{- if $image.exists -}}
  9. {{- $imagePermalink := "" -}}
  10. {{- if and $image.resource (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
  11. {{- $thumbnail := $image.resource.Fill "120x120" -}}
  12. {{- $imagePermalink = (absURL $thumbnail.Permalink) -}}
  13. {{- else -}}
  14. {{- $imagePermalink = $image.permalink -}}
  15. {{- end -}}
  16. {{- $data = merge $data (dict "image" (absURL $imagePermalink)) -}}
  17. {{- end -}}
  18. {{- $result = $result | append $data -}}
  19. {{- end -}}
  20. {{ jsonify $result }}