Skip to content

Instantly share code, notes, and snippets.

@savchukoleksii
Last active June 21, 2019 14:43
Show Gist options
  • Save savchukoleksii/00681cda4a98a2d57ae15bfe8655900f to your computer and use it in GitHub Desktop.
Save savchukoleksii/00681cda4a98a2d57ae15bfe8655900f to your computer and use it in GitHub Desktop.
{% assign previous_article = nil %}
{% assign previous_handle = blog.next_article.handle %}
{% if previous_handle %}
{% assign previous_article = articles[previous_handle] %}
{% endif %}
{% assign next_article = nil %}
{% assign next_handle = blog.previous_article.handle %}
{% if next_handle %}
{% assign next_article = articles[next_handle] %}
{% endif %}
{% unless previous_article %}
{% assign last_index = blog.articles_count | minus: 1 %}
{% assign previous_article = blog.articles[last_index] %}
{% endunless %}
{% unless next_article %}
{% assign next_article = blog.articles[0] %}
{% endunless %}
{% if previous_article.handle == article.handle %}
{% assign previous_article = nil %}
{% endif %}
{% if next_article.handle == article.handle %}
{% assign next_article = nil %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment