Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better pagination #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jekyll-archives:

# Pagination
paginate: 6
paginate_trail: 2
paginate_show_first_and_last: true
paginate_path: /page:num/

# Other
Expand Down
39 changes: 26 additions & 13 deletions _includes/pagination.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
{% if paginator.total_pages > 1 %}
<div class="pagination">
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center flex-wrap">

{% if paginator.previous_page %}
<a class="ml-1 mr-1" href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">&laquo; Prev</a>
{% else %}
<span>&laquo; Prev</span>
{% if site.paginate_show_first_and_last %}
<li class="page-item"><a class="page-link" href="{{ site.baseurl | replace: '//', '/' }}/" title="First page">&laquo;</a></li>
{% endif %}
<li class="page-item"><a class="page-link" href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}" title="Previous page">&lt;</a></li>
{% endif %}

{% for page in (1..paginator.total_pages) %}
{% if page == paginator.page %}
<span class="ml-1 mr-1">{{ page }}</span>
{% assign page_start = paginator.page | minus: site.paginate_trail %}
{% assign page_end = paginator.page | plus: site.paginate_trail %}

{% for page in (page_start..page_end) %}
{% if page < 1 %}
<!-- Do nothing -->
{% elsif page > paginator.total_pages %}
<!-- Do nothing -->
{% elsif page == paginator.page %}
<li class="page-item active"><a class="page-link">{{ page }} <span class="sr-only">(current)</span></a></li>
{% elsif page == 1 %}
<a class="ml-1 mr-1" href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">{{ page }}</a>
<li class="page-item"><a class="page-link" href="{{ site.baseurl | replace: '//', '/' }}/">{{ page }}</a></li>
{% else %}
<a class="ml-1 mr-1" href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a>
<li class="page-item"><a class="page-link" href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a></li>
{% endif %}
{% endfor %}

{% if paginator.next_page %}
<a class="ml-1 mr-1" href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">Next &raquo;</a>
{% else %}
<span>Next &raquo;</span>
<li class="page-item"><a class="page-link" href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}" title="Next page">&gt;</a></li>
{% if site.paginate_show_first_and_last %}
<li class="page-item"><a class="page-link" href="{{ site.baseurl | replace: '//', '/' }}/page{{ paginator.total_pages }}" title="Last page">&raquo;</a></li>
{% endif %}
{% endif %}
</div>

</ul>
</nav>
{% endif %}
34 changes: 34 additions & 0 deletions assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,37 @@
"syntax",
"starsnonscss"
;

/* pagination */

$paginateColor: #00ab6b;

.pagination > li > a
{
background-color: white;
color: $paginateColor;
}

.pagination > li > a:focus,
.pagination > li > a:hover,
.pagination > li > span:focus,
.pagination > li > span:hover
{
color: #5a5a5a;
background-color: #eee;
border-color: #ddd;
}

.pagination > .active > a
{
color: white;
background-color: $paginateColor !important;
border: solid 1px $paginateColor !important;
}

.pagination > .active > a:hover
{
background-color: $paginateColor !important;
border: solid 1px $paginateColor;
}
/* pagination end */
4 changes: 0 additions & 4 deletions assets/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,6 @@ span.navigation {
text-align: center;
}

.pagination {
display: block;
}

iframe {
max-width: 100%;
}
Expand Down