From b0f3b54dc1e3e6b94c9ae157f9480660559dc55f Mon Sep 17 00:00:00 2001 From: agusmakmun <summon.agus@gmail.com> Date: Wed, 20 Apr 2016 18:00:25 +0700 Subject: [PATCH] update paginator --- _config.yml | 4 ++-- index.html | 30 +++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/_config.yml b/_config.yml index 5b34234..c3e180e 100644 --- a/_config.yml +++ b/_config.yml @@ -12,7 +12,7 @@ urls: url: /feed.xml url: "https://agusmakmun.github.io" baseurl: "" -paginate: 20 -per_page: 20 +paginate: 3 +per_page: 3 paginate_path: "/page:num/" markdown: kramdown \ No newline at end of file diff --git a/index.html b/index.html index 95e9ba7..8e862b2 100644 --- a/index.html +++ b/index.html @@ -13,28 +13,40 @@ layout: default <!-- Pagination links --> {% if paginator.total_pages > 1 %} - <div class="pagination"> + <ul class="pagination"> {% if paginator.previous_page %} - <a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">« Prev</a> + <li> + <a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">«</a> + </li> {% else %} - <span>« Prev</span> + <li class="disabled"><span aria-hidden="true">«</span></li> {% endif %} + <li><a href="/">First</a></li> + {% for page in (1..paginator.total_pages) %} {% if page == paginator.page %} - <em>{{ page }}</em> + <li class="active"> + <a>{{ page }}<span class="sr-only">(current)</span></a> + </li> {% elsif page == 1 %} - <a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">{{ page }}</a> + <li><a href="/">{{ page }}</a></li> {% else %} - <a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a> + <li> + <a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a> + </li> {% endif %} {% endfor %} + <li><a href="/page{{ paginator.total_pages }}/">Last</a></li> + {% if paginator.next_page %} - <a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">Next »</a> + <li> + <a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">»</a> + </li> {% else %} - <span>Next »</span> + <li class="disabled"><span>»</span></li> {% endif %} - </div> + </ul> {% endif %} </div><!-- end #home --> -- GitLab