Skip to content

Commit

Permalink
Merge pull request datacarpentry#121 from gvwilson/prev-next
Browse files Browse the repository at this point in the history
Using page.previous and page.next for links instead of loop
  • Loading branch information
rgaiacs authored Jan 9, 2017
2 parents c8f6fdc + 61ad44f commit f5d8968
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions _includes/episode_navbar.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
{% comment %}
Find previous and next episodes (if any).
{% endcomment %}
{% for episode in site.episodes %}
{% if episode.url == page.url %}
{% unless forloop.first %}
{% assign prev_episode = prev %}
{% endunless %}
{% unless forloop.last %}
{% assign next_episode = site.episodes[forloop.index] %}
{% endunless %}
{% endif %}
{% assign prev = episode %}
{% endfor %}

{% comment %}
Display title and prev/next links.
Navigation bar for an episode.
{% endcomment %}
<div class="row">
<div class="col-md-1">
<h3>
{% if prev_episode %}
<a href="{{ page.root }}{{ prev_episode.url }}"><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span><span class="sr-only">previous episode</span></a>
{% if page.previous.url %}
<a href="{{ page.root }}{{ page.previous.url }}"><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span><span class="sr-only">previous episode</span></a>
{% else %}
<a href="{{ page.root }}/"><span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span><span class="sr-only">lesson home</span></a>
{% endif %}
Expand All @@ -34,8 +19,8 @@ <h1 class="maintitle">{{ page.title }}</h1>
</div>
<div class="col-md-1">
<h3>
{% if next_episode %}
<a href="{{ page.root }}{{ next_episode.url }}"><span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span><span class="sr-only">next episode</span></a>
{% if page.next.url %}
<a href="{{ page.root }}{{ page.next.url }}"><span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span><span class="sr-only">next episode</span></a>
{% else %}
<a href="{{ page.root }}/"><span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span><span class="sr-only">lesson home</span></a>
{% endif %}
Expand Down

0 comments on commit f5d8968

Please sign in to comment.