hugo-blog/themes/eddie/layouts/_default/index.json

22 lines
708 B
JSON
Raw Normal View History

2022-08-16 20:42:05 +00:00
{{- $.Scratch.Add "index" slice -}}
{{- range where site.RegularPages "Type" "in" site.Params.mainSections -}}
{{ $image:= .Params.image }}
{{ if $image }}
{{ if hasPrefix $image "http" }}
{{ $.Scratch.Set "image" ($image | safeURL) }}
{{ else }}
{{ if fileExists (add `assets/` .Params.image) }}
{{ $img:= resources.Get (.Params.image) }}
{{ $img:= $img.Fill "420x280 webp"}}
{{ $.Scratch.Set "image" ($img.RelPermalink) }}
{{ end }}
{{ end }}
{{ end }}
{{ $image := $.Scratch.Get "image" }}
{{- $.Scratch.Add "index" (dict "title" .Title "tags" .Params.tags "image" $image "categories" .Params.categories "contents" .Plain "permalink" .Permalink) -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}