aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_includes/posts
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-04-08 21:48:53 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-04-08 21:48:53 +0300
commitb0b39768de6564e21f28c96fca34e01fa4602116 (patch)
treeceb9d21a153dd99bd0aa500d9da3c2c3e3172e8f /_includes/posts
parent_includes: add posts.html (diff)
downloadjekyll-theme-b0b39768de6564e21f28c96fca34e01fa4602116.tar.gz
jekyll-theme-b0b39768de6564e21f28c96fca34e01fa4602116.zip
_includes: move paginator.html to posts
Diffstat (limited to '_includes/posts')
-rw-r--r--_includes/posts/paginator.html36
-rw-r--r--_includes/posts/posts.html2
2 files changed, 37 insertions, 1 deletions
diff --git a/_includes/posts/paginator.html b/_includes/posts/paginator.html
new file mode 100644
index 0000000..471383c
--- /dev/null
+++ b/_includes/posts/paginator.html
@@ -0,0 +1,36 @@
+{% comment %}
+ Page links, inspired by the example at the bottom of
+ https://jekyllrb.com/docs/pagination/.
+{% endcomment %}
+{% if site.posts.size != 0 %}
+ {% 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 %}
+<ul class="pagination">
+ {% if paginator.previous_page %}
+ <li><a href="{{ paginator.previous_page_path | relative_url }}"><span class="glyphicon glyphicon-chevron-left"></span>&nbsp;Prev</a></li>
+ {% else %}
+ <li class="disabled"><a href="#"><span class="glyphicon glyphicon-chevron-left"></span>&nbsp;Prev</a></li>
+ {% endif %}
+ {% for page_number in (1..paginator.total_pages) %}
+ {% if page_number == paginator.page %}
+ <li class="active"><a href="#">{{ page_number }}</a></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&nbsp;<span class="glyphicon glyphicon-chevron-right"></span></a></li>
+ {% else %}
+ <li class="disabled"><a href="#">Next&nbsp;<span class="glyphicon glyphicon-chevron-right"></span></a></li>
+ {% endif %}
+</ul>
+{% endif %}
diff --git a/_includes/posts/posts.html b/_includes/posts/posts.html
index 4f52efc..724edc6 100644
--- a/_includes/posts/posts.html
+++ b/_includes/posts/posts.html
@@ -12,6 +12,6 @@
<hr/>
{% endfor %}
<div class="text-center">
- {% include common/paginator.html %}
+ {% include posts/paginator.html %}
</div>
{% endif %}