This navigator is not only good for collectins. If you have a multilingual blog like me you might want to use this for posts as well because it’s rather hard with the paginator, sinve multilingual posts are not natively supported by jekyll. So that’s why I went with this solution. Every post of mine has a lang
variable.
1 {% assign document = site.posts | sort: "date" | reversed | where:"lang", page.lang %}2 {% for links in document %}3 {% if links.title == page.title %}4
5 {% unless forloop.first %}6 {% assign prevurl = prev.url %}7
8 {% assign prevtitle = prev.title %}9 {% endunless %}10
11 {% unless forloop.last %}12 {% assign next = document[forloop.index] %}13 {% assign nexturl = next.url %}14 {% assign nexttitle = next.title %}15 {% endunless %}16
17 {% endif %}18
19 {% assign prev = links %}20 {% endfor %}21
22 {% if prevurl or nexturl %}23 <div class="pagination">24 {% if prevurl %}<a href="{{prevurl}}" class="prev"><i class="fa fa-angle-left"></i> {{ prevtitle}}</a>{% endif %}25 {% if nexturl %}<a href="{{nexturl}}" class="next">{{nexttitle}} <i class="fa fa-angle-right"></i></a>{% endif %}26 </div>27 {% endif %}