{% 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 %}