Created
April 18, 2017 17:06
-
-
Save yohangdev/c5caab1d10a1174dd16a677d36b1ccdf to your computer and use it in GitHub Desktop.
Jekyll Collections Pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% for c in site.tripcollection %} | |
| {% if c.title == page.title %} | |
| {% assign thisPost = c %} | |
| {% if forloop.index == 1 %} | |
| {% assign prevflag = 0 %} | |
| {% assign nextflag = 1 %} | |
| {% elsif forloop.index == forloop.length %} | |
| {% assign prevflag = 1 %} | |
| {% assign nextflag = 0 %} | |
| {% else %} | |
| {% assign prevflag = 1 %} | |
| {% assign nextflag = 1 %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% for c in site.tripcollection %} | |
| {% if c.title == page.title %} | |
| {% assign prevflag = 0 %} | |
| {% endif %} | |
| {% if prevflag == 1 %} | |
| {% assign prevPost = c %} | |
| {% assign page.previous = c %} | |
| {% endif %} | |
| {% endfor %} | |
| {% if nextflag == 1 %} | |
| {% for c in site.tripcollection %} | |
| {% if foundPost == 1 %} | |
| {% assign getNext = 1 %} | |
| {% endif %} | |
| {% if c.title == page.title %} | |
| {% assign foundPost = 1 %} | |
| {% endif %} | |
| {% if getNext == 1%} | |
| {% assign nextPost = c %} | |
| {% assign page.next = c %} | |
| {% assign foundPost = 0 %} | |
| {% assign getNext = 0 %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endif %} | |
| <div id="post-nav"> | |
| <div > | |
| {% if prevPost.url %} | |
| <a class="prev" href="{{prevPost.url}}"> | |
| <span>< {{prevPost.title}}</span> | |
| </a> | |
| {% endif %} | |
| {% if nextPost.url %} | |
| <a class="next" href="{{nextPost.url}}"> | |
| <span>{{nextPost.title}} ></span> | |
| </a> | |
| {% endif %} | |
| </div> | |
| </div> | |
| <!-- original: http://anjesh.github.io/2015/01/25/collection-pagination-working-github-pages/ --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment