What’s the correct way to detect whether the current post is the first/last post? This functionality seems to be available in nav and pagination, but I haven’t found a good way of doing it in the post context. I’m imagining something like this:
<a class="btn next-post {{#unless next_post}}disabled{{/unless}}" href="{{#next_post}}{{url}}{{/next_post}}"> Next Post</a>
Thanks for your help!
You can use:
{{#if @first}} {{/if}}
{{#if @last}} {{/if}}
More info at:
Thanks @ahmadajmi.
I was hoping to use something like @first
and @last
, but unless I’m mistaken, they only work within a foreach loop.
I’m looking for something that will work in post.hbs.
You can try something like this:
<a class="btn next-post {{^next_post}}disabled{{/next_post}}" href="{{#next_post}}{{url}}{{/next_post}}"> Next Post</a>
1 Like
@HauntedThemes Perfect! That’s exactly what I was looking for. (I only tried tried those helpers with if/unless for some reason)