Knowing a page's place in its sorted order

I’m trying to set up a static web comic site using Zola, which means each page in a section needs a footer with a link to its predecessor and successor.

I’m going trial and error to try to get the hang of hte Tera syntax to figure out how a page
can find itself in the sorted order of pages for the secion, and add the link to these in the footer, and not having much luck.

This comes pretty close but no cigar:

{{ section.pages | map(attribute=“slug”) | slice(end=page.slug) | last }}

(I’m working on the assumption that I’ll be sorting through slugs).

Has anyone done this yet?

I’ve achieved this in 2 ways in the past.

  1. Use loop.index when iterating
  2. Set the weight value in each file’s frontmatter and query that in your template.
  <img src="/comic/First.png"></a>
{% if page.lower %}
<a class="next" href="{{ page.lower.permalink }}"> {{ page.lower.title }}</a>
{% endif %}
{% if page.higher %}
<a class="next" href="{{ page.higher.permalink }}"> {{ page.higher.title }}</a>
{% endif %}
{{ section.pages | map(attribute="slug") | last }}

This is working.