blob: 597e2c670c5c7f89a364e56fd9f3a022cf1f1308 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
{% comment %}
Page links, inspired by the example at the bottom of
https://jekyllrb.com/docs/pagination/.
{% endcomment %}
{% if paginator.total_pages > 1 %}
{% capture prev %}<span class="glyphicon glyphicon-chevron-left"></span>{% endcapture %}
{% capture next %}<span class="glyphicon glyphicon-chevron-right"></span>{% endcapture %}
{% comment %}
Link to page 1 is tricky. If site.paginate_path is used, then we cannot
simply use /. This is a silly attempt to get the proper page 1 link.
{% endcomment %}
{% if paginator.page == 1 %}
{% assign page1_url = page.url %}
{% else %}
{% assign page1_url = page.url | split: '/' | pop | join: '/' | append: '/' %}
{% endif %}
<div class="text-center">
<ul class="pagination">
{% if paginator.previous_page %}
<li>
<a href="{{ paginator.previous_page_path | relative_url }}">{{ prev }}</a>
</li>
{% else %}
<li class="disabled">
<span>{{ prev }}</span>
</li>
{% endif %}
{% for page_number in (1..paginator.total_pages) %}
{% if page_number == paginator.page %}
<li class="active">
<span>{{ page_number }}</span>
</li>
{% elsif page_number == 1 %}
<li>
<a href="{{ page1_url | relative_url }}">{{ page_number }}</a>
</li>
{% else %}
<li>
<a href="{{ site.paginate_path | replace: ':num', page_number | relative_url }}">{{ page_number }}</a>
</li>
{% endif %}
{% endfor %}
{% if paginator.next_page %}
<li>
<a href="{{ paginator.next_page_path | relative_url }}">{{ next }}</a>
</li>
{% else %}
<li class="disabled">
<span>{{ next }}</span>
</li>
{% endif %}
</ul>
</div>
{% endif %}
|