Update pagination example

This commit is contained in:
张君君 2013-09-26 00:11:06 +08:00
parent d800cdcc31
commit dd6d0b42fe
1 changed files with 17 additions and 37 deletions

View File

@ -182,51 +182,31 @@ page with links to all but the current page.
{% highlight html %}
{% raw %}
<div id="post-pagination" class="pagination">
{% if paginator.total_pages > 1 %}
<!-- Pagination: https://gist.github.com/jsw0528/4720584 -->
<div class="pagination">
{% if paginator.previous_page %}
<p class="previous">
{% if paginator.previous_page == 1 %}
<a href="/">Previous</a>
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">&laquo; Prev</a>
{% else %}
<a href="{{ paginator.previous_page_path }}">Previous</a>
{% endif %}
</p>
{% else %}
<p class="previous disabled">
<span>Previous</span>
</p>
<span>&laquo; Prev</span>
{% endif %}
<ul class="pages">
<li class="page">
{% if paginator.page == 1 %}
<span class="current-page">1</span>
{% for page in (1..paginator.total_pages) %}
{% if page == paginator.page %}
<em>{{ page }}</em>
{% elsif page == 1 %}
<a href="{{ '/index.html' | prepend: site.baseurl | replace: '//', '/' }}">{{ page }}</a>
{% else %}
<a href="/">1</a>
<a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a>
{% endif %}
</li>
{% for count in (2..paginator.total_pages) %}
<li class="page">
{% if count == paginator.page %}
<span class="current-page">{{ count }}</span>
{% else %}
<a href="/page{{ count }}">{{ count }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
{% if paginator.next_page %}
<p class="next">
<a href="{{ paginator.next_page_path }}">Next</a>
</p>
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">Next &raquo;</a>
{% else %}
<p class="next disabled">
<span>Next</span>
</p>
<span>Next &raquo;</span>
{% endif %}
</div>
{% endif %}
{% endraw %}
{% endhighlight %}