Hi! I currently have a code snippet that lists out a preview of a load of recommended travel experience pages:
<h3 id="experiences">Recommended Experiences</h3>
{{ range where .Data.Pages.ByWeight "Section" "experiences" }}
<a class="experiences-link" href="{{ .Permalink }}" target="_blank">
<div class="experiences-section">
<h4>{{ .Title }}</h4>
<h5>{{ .Params.Summary }} - {{ .Params.Duration }}</h5>
</div>
</a>
{{ end }}
That all works great. But now I want to add an image to each. For even numbered ones (first one will be 0, so first is 0, 3rd is 2 and so on) I want the image to the right, text to the left. And for odd numbers, the other way round.
I found this topic
I assume I could modify the suggestion there to the following:
{{ $index, $element := range (where .Data.Pages.ByWeight "Section" "experiences") }}
Is there an easy way to check if $index is odd or even?