From 9de64a06625eca27a406440da3087d7f9cbd14b9 Mon Sep 17 00:00:00 2001 From: Greg Wilson <gvwilson@third-bit.com> Date: Thu, 14 Jul 2016 13:40:18 -0400 Subject: [PATCH] Cleaning up prev/next logic --- _includes/episode_find_prev_next.html | 14 -------------- _includes/episode_title.html | 27 ++++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 17 deletions(-) delete mode 100644 _includes/episode_find_prev_next.html diff --git a/_includes/episode_find_prev_next.html b/_includes/episode_find_prev_next.html deleted file mode 100644 index a8007e1..0000000 --- a/_includes/episode_find_prev_next.html +++ /dev/null @@ -1,14 +0,0 @@ -{% 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 %} diff --git a/_includes/episode_title.html b/_includes/episode_title.html index 5e2e4ec..7ea24a2 100644 --- a/_includes/episode_title.html +++ b/_includes/episode_title.html @@ -1,11 +1,30 @@ -{% include episode_find_prev_next.html %} +{% 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. +{% endcomment %} <div class="row"> <div class="col-md-1"> <h3> {% if prev_episode %} <a href="{{ site.github.url }}{{ prev_episode.url }}"><span class="glyphicon glyphicon-menu-left"></span></a> - {% else %} + {% elsif site.github.url %} <a href="{{ site.github.url }}"><span class="glyphicon glyphicon-menu-up"></span></a> + {% else %} + <a href="/"><span class="glyphicon glyphicon-menu-up"></span></a> {% endif %} </h3> </div> @@ -17,8 +36,10 @@ <h3> {% if next_episode %} <a href="{{ site.github.url }}{{ next_episode.url }}"><span class="glyphicon glyphicon-menu-right"></span></a> - {% else %} + {% elsif site.github.url %} <a href="{{ site.github.url }}"><span class="glyphicon glyphicon-menu-up"></span></a> + {% else %} + <a href="/"><span class="glyphicon glyphicon-menu-up"></span></a> {% endif %} </h3> </div> -- GitLab