{% comment %} Map grabs the doc sections, giving us an array of arrays. Join, flattens all the items to a comma delimited string. Split turns it into an array again. {% endcomment %} {% assign docs = site.data.docs | map: 'docs' | join: ',' | split: ',' %} {% comment %} Because this is built for every page, lets find where we are in the ordered document list by comparing url strings. Then if there's something previous or next, lets build a link to it. {% endcomment %} {% for document in docs %} {% assign document_url = document | prepend:"/docs/" | append:".html" %} {% if document_url == page.url %}
{% if forloop.first %} Previous {% else %} {% assign previous = forloop.index0 | minus: 1 %} {% capture previous_page %}{{ site.baseurl }}{{docs[previous] | prepend:"/docs/" | append:".html" }}{% endcapture %} {% endif %}
{% if forloop.last %} Next {% else %} {% assign next = forloop.index0 | plus: 1 %} {% capture next_page %}{{ site.baseurl }}{{ docs[next] | prepend:"/docs/" | append:".html" }}{% endcapture %} {% comment %} See CALCITE-2036 for an explanation of the replacement below {% endcomment %} {% endif %}
{% break %} {% endif %} {% endfor %}