How can I use $.Site.GetPage from a partial in a range loop?
_index.md
blocks:
- title: Ultieme keuzevrijheid
subtitle: Betaal enkel voor wat je nodig hebt
image: "uploads/hero-phone.jpg"
index.html
{{ with .Params.blocks }}
{{ range . }}
{{- partial "card.html" (dict "item" . "ctx" $) -}}
{{ end }}
{{ end }}
partials/card.html
{{$ctx := .ctx}}
{{ with .item.image}}
{{ . }}
{{ $ctx.Site}}
{{ $imageResource := ($ctx.Site.GetPage "section" "uploads").Resources.GetMatch (strings.TrimPrefix "/uploads/" . ) }}
{{ with $imageResource }}
{{ $src1x := (.Fill "400x300 Center") }}
{{ $src2x := (.Fill "800x600 Center") }}
<picture class="block w-full h-full">
<img src="{{ $src1x.RelPermalink }}" srcset="{{ $src1x.RelPermalink }} 1x, {{ $src2x.RelPermalink }} 2x" class="block w-full h-full" style="object-fit:cover;" />
</picture>
{{ end }}
{{ end }}
$imageResource returns nothing. $ctx.Site is returning the site name. So seems that the dict function is working correctly.