Last active
February 27, 2016 17:10
-
-
Save code-nation/5fb265f87eb426a385f4 to your computer and use it in GitHub Desktop.
Step 1 of 2: Add Next and Previous links to blog posts on your NationBuilder site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign ordered_posts = page.parent.children | sort:'published_at' %} | |
{% for post in ordered_posts %} | |
{% if post.id == page.id %} | |
{% assign previous_post_number = forloop.index | minus:1 %} | |
{% assign next_post_number = forloop.index | plus:1 %} | |
{% endif %} | |
{% endfor %} | |
{% for post in ordered_posts %} | |
{% if forloop.index == previous_post_number %} | |
{% assign previous_post = post %} | |
{% elsif forloop.index == next_post_number %} | |
{% assign next_post = post %} | |
{% endif %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment