From c388d4e272eca8e7d98f8875c175c07c8bcc4772 Mon Sep 17 00:00:00 2001 From: Augustin Lemesle <augustin.lemesle@cea.fr> Date: Wed, 17 Jun 2020 09:56:41 +0200 Subject: [PATCH] fix pagination --- _layouts/blog.html | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/_layouts/blog.html b/_layouts/blog.html index ff6a87cc..62f998c4 100644 --- a/_layouts/blog.html +++ b/_layouts/blog.html @@ -57,25 +57,33 @@ css: blog </div> {% if paginator.total_pages > 1 %} + {% if page.category %} + {% assign path = "/category/:cat/page:num.html" | replace: ":cat", page.category %} + {% assign index = "/category/:cat/index.html" | replace: ":cat", page.category %} + {% else %} + {% assign path = site.paginate_path %} + {% assign index = "/blog/index.html"%} + {% endif %} + <div class="pagination clearfix"> {% if paginator.previous_page %} <a class="prev page-numbers" href="{{ paginator.previous_page_path }}">« Previous</a> {% if paginator.previous_page != 1 %} - <a class='page-numbers' href="/blog/index.html">{{ 1 }}</a> + <a class='page-numbers' href="{{ index }}">{{ 1 }}</a> ... {% endif %} {% if paginator.previous_page == 1%} - <a class='page-numbers' href="/blog/index.html">{{ 1 }}</a> + <a class='page-numbers' href="{{ index }}">{{ 1 }}</a> {% else %} - <a class='page-numbers' href="{{ site.paginate_path | replace: ':num', paginator.previous_page }}">{{ paginator.previous_page }}</a> + <a class='page-numbers' href="{{ path | replace: ':num', paginator.previous_page }}">{{ paginator.previous_page }}</a> {% endif %} {% endif %} <span class='page-numbers current'>{{ paginator.page }}</span> {% if paginator.next_page %} - <a class='page-numbers' href="{{ site.paginate_path | replace: ':num', paginator.next_page }}">{{ paginator.next_page }}</a> - {% if paginator.previous_page != paginator.total_pages %} + <a class='page-numbers' href="{{ path | replace: ':num', paginator.next_page }}">{{ paginator.next_page }}</a> + {% if paginator.next_page != paginator.total_pages %} ... - <a class='page-numbers' href="{{ site.paginate_path | replace: ':num', paginator.total_pages }}">{{ paginator.total_pages }}</a> + <a class='page-numbers' href="{{ path | replace: ':num', paginator.total_pages }}">{{ paginator.total_pages }}</a> {% endif %} <a class="next page-numbers" href="{{ paginator.next_page_path }}">Next »</a> {% endif %} -- GitLab