Skip to content

Commit

Permalink
Extract page list creation & fix breadcrumb buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosperate committed Nov 8, 2019
1 parent 96cc8b1 commit e7d1780
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 62 deletions.
16 changes: 9 additions & 7 deletions _includes/breadcrumbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
{% endif %}
</li>
</ul>
{% if config.theme.prev_next_buttons_location|lower in ['top', 'both']
and page and (page.next_page or page.previous_page) %}

{%- include paginationlist.html %}
{%- if (site.prev_next_buttons_location == 'bottom' or site.prev_next_buttons_location =='both') and (previous_page or next_page) %}
<div class="rst-breadcrumbs-buttons" role="navigation" aria-label="breadcrumb navigation">
{%- if page.next_page %}
<a href="{{ page.next_page.url|url }}" class="btn btn-neutral float-right" title="{{ page.next_page.title }}">Next <span class="icon icon-circle-arrow-right"></span></a>
{%- if next_page %}
<a href="{{ next_page.url | url }}" class="btn btn-neutral float-right" title="{{ next_page.title }}">Next <span class="icon icon-circle-arrow-right"></span></a>
{%- endif %}
{%- if page.previous_page %}
<a href="{{ page.previous_page.url|url }}" class="btn btn-neutral" title="{{ page.previous_page.title }}"><span class="icon icon-circle-arrow-left"></span> Previous</a>
{%- if previous_page %}
<a href="{{ previous_page.url | url }}" class="btn btn-neutral" title="{{ previous_page.title }}"><span class="icon icon-circle-arrow-left"></span> Previous</a>
{%- endif %}
</div>
{% endif %}
{%- endif %}

<hr/>
</div>
68 changes: 14 additions & 54 deletions _includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,62 +1,22 @@
<footer>
{%- comment -%}
Jekyll doesn't offer a way to see if there are next or previous pages, it'
only available for posts. So we will iterate through the pages like we do
on the navigation bar and store the previous and next URLS.
{%- endcomment -%}
{%- assign previous_page = false -%}
{%- assign next_page = false -%}
{%- assign nav = site.pages | sort:"nav_order" -%}
{%- assign found = false -%}

{%- for nav_item in nav -%}
{%- if nav_item.hide != true and nav_item.nav_exclude != true -%}
{%- if nav_item.url == page.url -%}
{%- assign found = true -%}
{% break %}
{%- else -%}
{%- assign previous_page = nav_item -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- if found == false -%}
{%- assign previous_page = false -%}
{%- endif -%}

{%- assign found = false -%}
{%- for nav_item in nav reversed -%}
{%- if nav_item.hide != true and nav_item.nav_exclude != true -%}
{%- if nav_item.url == page.url -%}
{%- assign found = true -%}
{% break %}
{%- else -%}
{%- assign next_page = nav_item -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- if found == false -%}
{%- assign next_page = false -%}
{%- endif -%}

{% if (site.prev_next_buttons_location == 'bottom' or site.prev_next_buttons_location =='both') and (previous_page or next_page) %}
{%- include paginationlist.html %}
{%- if (site.prev_next_buttons_location == 'bottom' or site.prev_next_buttons_location =='both') and (previous_page or next_page) %}
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
{% if next_page %}
{%- if next_page %}
<a href="{{ next_page.url | url }}" class="btn btn-neutral float-right" title="{{ next_page.title }}">Next <span class="icon icon-circle-arrow-right"></span></a>
{% endif %}
{% if previous_page %}
{%- endif %}
{%- if previous_page %}
<a href="{{ previous_page.url | url }}" class="btn btn-neutral" title="{{ previous_page.title }}"><span class="icon icon-circle-arrow-left"></span> Previous</a>
{% endif %}
{%- endif %}
</div>
{% endif %}
{%- endif %}

<hr/>
<hr/>

<div role="contentinfo">
<!-- Copyright etc -->
{% if site.site_author %}
<p>© Copyright {{ site.time | date: "%Y" }} {{ site.site_author }}.</p>
{% endif %}
</div>

Built with <a href="https://jekyllrb.com/">Jekyll</a> using a <a href="https://github.com/carlosperate/jekyll-theme-rtd">theme</a> based on <a href="https://readthedocs.org">Read the Docs</a>.
<div role="contentinfo">
{%- if site.site_author %}
<p>© Copyright {{ site.time | date: "%Y" }} {{ site.site_author }}.</p>
{%- endif %}
</div>
Built with <a href="https://jekyllrb.com/">Jekyll</a> using a <a href="https://github.com/carlosperate/jekyll-theme-rtd">theme</a> based on <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
39 changes: 39 additions & 0 deletions _includes/paginationlist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

{%- comment -%}
Jekyll doesn't offer a way to see if there are next or previous pages, it'
only available for posts. So we will iterate through the pages like we do
on the navigation bar and store the previous and next URLS.
{%- endcomment -%}
{%- assign previous_page = false -%}
{%- assign next_page = false -%}
{%- assign nav = site.pages | sort:"nav_order" -%}
{%- assign found = false -%}

{%- for nav_item in nav -%}
{%- if nav_item.hide != true and nav_item.nav_exclude != true -%}
{%- if nav_item.url == page.url -%}
{%- assign found = true -%}
{% break %}
{%- else -%}
{%- assign previous_page = nav_item -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- if found == false -%}
{%- assign previous_page = false -%}
{%- endif -%}

{%- assign found = false -%}
{%- for nav_item in nav reversed -%}
{%- if nav_item.hide != true and nav_item.nav_exclude != true -%}
{%- if nav_item.url == page.url -%}
{%- assign found = true -%}
{% break %}
{%- else -%}
{%- assign next_page = nav_item -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- if found == false -%}
{%- assign next_page = false -%}
{%- endif -%}
3 changes: 2 additions & 1 deletion search_data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
layout: null
nav_exclude: true
search_exclude: true
---
{
Expand Down Expand Up @@ -28,4 +29,4 @@ search_exclude: true
".": "."
}
{%- endfor %}
}
}

0 comments on commit e7d1780

Please sign in to comment.