I have a collection which I use collection:previous
and collection:next
on to create a "prev/next item"-navigation, like so:
{{ collection:previous in "myCollection" as="item" limit="1" wrap="true" }}
{{ item }}
\\ Do something
{{ /item }}
{{ /collection:previous }}
Now, where it gets interesting is that every collection entry has a featured image that I'd like to use for this navigation:
{{ collection:previous in "myCollection" as="item" limit="1" wrap="true" }}
{{ item }}
<div style="background-image: url('{{ if featured_image }}{{ featured_image }}{{ else }}/assets/img/path-to-fallback-image.jpg{{ /if }}')">
<p>Previous item</p>
</div>
{{ /item }}
{{ /collection:previous }}
What I've found is that if the previous post has no featured_image
, it falls back to the featured_image
of the page we're currently on:
- Previous item's featured image, else:
- Current item's featured image, else:
- Fallback image
But what I'd really, really like:
- Previous item's featured image, else:
- Fallback image
What am I missing?