Created
December 7, 2011 04:25
-
-
Save davefearon/1441453 to your computer and use it in GitHub Desktop.
Jekyll + Liquid + pagination = win!
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
paginate: 5 |
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
<article data-link="{{ post.url }}"> | |
<header> | |
<h2>{{ post.title }}</h2> | |
<h6>Posted on <time datetime="{{ post.date }}" pubdate>{{ post.date | date_to_string }}</time></h6> | |
<hr> | |
</header> | |
{{ post.content }} | |
<footer> | |
<p class="tags"> | |
Tags: | |
{% for tag in post.tags %} | |
<a href="#" class="capitalize">{{ tag }}</a> | |
{% if forloop.last != true %},{% endif %} | |
{% endfor %} | |
<span class="readmore"><a href="{{ post.url }}">Read More</a></span> | |
</p> | |
</footer> | |
</article> |
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
<section class="content"> | |
{% for post in paginator.posts %} | |
{% include frontpage_post %} | |
{% endfor %} | |
</section> | |
{% if paginator.total_pages != 1 %} | |
<section class="pagination"> | |
<ul> | |
{% for i in (1..paginator.total_pages) %} | |
{% if forloop.first == true %} | |
{% if paginator.page == 1 %} | |
<li class="prev disabled"><a>← Previous</a></li> | |
{% else %} | |
{% if paginator.page == 2 %} | |
<li class="prev"><a href="{{ site.url }}">← Previous</a></li> | |
{% else %} | |
<li class="prev"><a href="{{ site.url }}/page/{{ paginator.previous_page }}">← Previous</a></li> | |
{% endif %} | |
{% endif %} | |
{% endif %} | |
{% if paginator.page == i %} | |
<li class="disabled"><a>{{ i }}</a></li> | |
{% else %} | |
{% if i == 1 %} | |
<li><a href="{{ site.url }}">{{ i }}</a></li> | |
{% else %} | |
<li><a href="{{ site.url }}/page/{{ i }}">{{ i }}</a></li> | |
{% endif %} | |
{% endif %} | |
{% if forloop.last == true %} | |
{% if paginator.page == paginator.total_pages %} | |
<li class="next disabled"><a>Next →</a></li> | |
{% else %} | |
<li class="next"><a href="{{ site.url }}/page/{{ paginator.next_page }}">Next →</a></li> | |
{% endif %} | |
{% endif %} | |
{% endfor %} | |
</ul> | |
</section> | |
{% endif %} |
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
# find the following line: | |
newpage.dir = File.join(page.dir, "page#{num_page}") | |
# edit it to be the following: | |
newpage.dir = File.join(page.dir, "page/#{num_page}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment