Hi,
I’ trying to dynamically access front matter info from within a shortcode:
Front matter:
gallery-1:
- src: image1.jpg
- src: image2.jpg
- src: image9.jpg
gallery-2:
- src: image3.jpg
- src: image4.jpg
The shortcode should be something like
{{< gallery id="2" >}}
How can I dynamically get the front matter info from within a shortcode?
Trying to get a range working with a string obviously doesn’t work, but I can’t figure out how to do it right …
{{ $index := $.Get "id" }}
{{ $gallery := printf ".Page.Params.gallery-%s" $index }}
{{ range $gallery }}
{{ end }}
Given error is
range can’t iterate over .Page.Params.gallery
Which is totally reasonable as range can’t iterate over a string - but how can I build the name of the collection so range can work with it?