hugo-theme-stack-stars/layouts/page/search.json
Jimmy Cai 2ad65a4c07
feat: add option to disable image processing (#83)
* feat: add option to disable image processing

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/37

* refactor(list): use article/components/header inside default.html

* refactor: use .Fill for cover image
2020-12-23 21:02:35 +01:00

24 lines
No EOL
999 B
JSON

{{- $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" (.Plain) -}}
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
{{- if and $image.exists $image.resource -}}
{{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
{{- $thumbnail := $image.resource.Fill "120x120" -}}
{{- $image := dict "image" (absURL $thumbnail.Permalink) -}}
{{- else -}}
{{- $image := dict "image" (absURL $image.resource.Permalink) -}}
{{- end -}}
{{- $data = merge $data $image -}}
{{ end }}
{{- $result = $result | append $data -}}
{{- end -}}
{{ jsonify $result }}