I’m trying to create a shortcode that ranges through any images from the page resources and displays them. My code is below:
<div class="gallery">
<ul>
{{ range .Page.Resources.Match "**.png" }}
<li>
<a href="{{ .RelPermalink }}">
<img src="{{ .RelPermalink }}">
</a>
</li>
{{ end }}
</ul>
</div>
I include this into _index.md like so:
{{< gallery >}}
Within the frontmatter of _index.md I have the following resources defined:
[[resources]]
src = "featured-work/1.png"
title = ""
[[resources]]
src = "featured-work/2.png"
title = ""
[[resources]]
src = "featured-work/3.png"
title = ""
Within content
I have a featured-work
directory that contains the images.
The gallery code is being loaded into the html source but the list is empty.
Any idea what I’m doing wrong?