Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmistakes/43a355923921d22cd993 to your computer and use it in GitHub Desktop.
Save mmistakes/43a355923921d22cd993 to your computer and use it in GitHub Desktop.
{% capture the_collection %}{{ page.collection }}{% endcapture %}
{% if page.collection %}
{% assign document = site[the_collection] %}
{% endif %}
{% for links in document %}
{% if links.title == page.title %}
{% unless forloop.first %}
{% assign prevurl = prev.url %}
{% assign prevtitle = prev.title %}
{% endunless %}
{% unless forloop.last %}
{% assign next = document[forloop.index] %}
{% assign nexttitle = next.title %}
{% assign nexturl = next.url %}
{% endunless %}
{% endif %}
{% assign prev = links %}
{% endfor %}
{% if prevurl %}<a href="{{ prevurl }}">Previous: {{ prevtitle l}}</a>{% endif %}<br />
{% if nexturl %}<a href="{{ nexturl }}">Next: {{ nexttitle }}</a>{% endif %}
<script>
/* post pagination keyboard shortcuts */
document.body.onkeyup = function(e){
if (e.keyCode == '37') { window.location = '{{ prevurl }}'; } // left arrow key
if (e.keyCode == '39') { window.location = '{{ nexturl }}'; } // right arrow key
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment