Skip to content

Commit

Permalink
That one failed, use own code from mmistakes/minimal-mistakes#2636
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Aug 10, 2020
1 parent 319e38f commit a152d46
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions _includes/paginator.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% if paginator.total_pages > 1 %}
<nav class="pagination">
{% assign first_page_path = paginator.first_page_path | default: site.paginate_path | replace: 'page:num', '' | replace: '//', '/' | remove: 'index.html' | relative_url %}
<ul>
{% comment %} Link for previous page {% endcomment %}
{% if paginator.previous_page %}
Expand All @@ -13,7 +12,7 @@
<li><a href="#" class="disabled"><span aria-hidden="true"><i class="fas fa-caret-left"></i> <span class="sr-only">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</span></span></a></li>
{% endif %}

{% comment %} Determine whether the first page and the last page are already included {% endcomment %}
{% comment %} Determine whether the first page and the last page are already included in trail {% endcomment %}
{% for trail in paginator.page_trail %}
{% if trail.num == paginator.first_page %}
{% assign has_first_page = true %}
Expand All @@ -27,41 +26,36 @@
{% if paginator.page == 1 %}
<li><a href="#" class="disabled current">1</a></li>
{% else %}
<li><a href="{{ first_page_path }}">1</a></li>
<li><a href="{{ paginator.first_page_path | relative_url }}">1</a></li>
{% endif %}
{% endunless %}

{% assign page_start = 2 %}
{% if paginator.page > 4 %}
{% assign page_start = paginator.page | minus: 2 %}
{% comment %} Ellipsis for truncated links {% endcomment %}
{% comment %} Ellipsis for truncated links {% endcomment %}
{% assign ellipsis_start = site.pagination.trail.before | plus: 2 %}
{% if paginator.page > ellipsis_start %}
<li><a href="#" class="disabled">&hellip;</a></li>
{% endif %}

{% assign page_end = paginator.total_pages | minus: 1 %}
{% assign pages_to_end = paginator.total_pages | minus: paginator.page %}
{% if pages_to_end > 4 %}
{% assign page_end = paginator.page | plus: 2 %}
{% endif %}

{% comment %} Main pagination trail {% endcomment %}
{% for trail in paginator.page_trail %}
{% if paginator.page == trail.num %}
<li><a href="{{ trail.path | relative_url | remove: 'index.html' }}" class="disabled current">{{ trail.num }}</a></li>
<li><a href="{{ trail.path | remove: 'index.html' | relative_url }}" class="disabled current">{{ trail.num }}</a></li>
{% else %}
<li><a href="{{ trail.path | relative_url | remove: 'index.html' }}">{{ trail.num }}</a></li>
<li><a href="{{ trail.path | remove: 'index.html' | relative_url }}">{{ trail.num }}</a></li>
{% endif %}
{% endfor %}

{% comment %} Ellipsis for truncated links {% endcomment %}
{% if pages_to_end > 3 %}
{% assign ellipsis_end = paginator.total_pages | minus: site.pagination.trail.after | minus: 1 %}
{% if paginator.page < ellipsis_end %}
<li><a href="#" class="disabled">&hellip;</a></li>
{% endif %}

{% unless has_last_page %}
{% if paginator.page == paginator.total_pages %}
<li><a href="#" class="disabled current">{{ paginator.page }}</a></li>
{% else %}
<li><a href="{{ paginator.last_page_path | relative_url | remove: 'index.html' }}">{{ paginator.total_pages }}</a></li>
<li><a href="{{ paginator.last_page_path | remove: 'index.html' | relative_url }}">{{ paginator.total_pages }}</a></li>
{% endif %}
{% endunless %}

Expand Down

0 comments on commit a152d46

Please sign in to comment.