Limit previous-next to parent section

I am making a section with a section tree of /content/chapter/article/article.md. A chapter may have several article folders in it. I am grouping all posts by weight in ascending order (0-infinite). I want to show previous and next links below each post, but limit the posts to the parent section (the last post that appears is in another section in the sequence). How do I achieve this?

Solution as per guidance from here.

{{ $p := where site.RegularPages.ByWeight.Reverse "Section" "example-section" }}
          {{ with $p.Prev . }}
             <a aria-label="Previous page. {{ .Title}}" href="{{ .Permalink }}">« {{ .Title }}</a>
          {{ end }}
          {{ with $p.Next . }}
             <a arial-label="Next page. {{ .Title }}" href="{{ .Permalink }}">{{ .Title }} »</a>
          {{ end }}

Would be nice in a forum to hear how you solved it? Otherwise it looks like you’re just collecting “Solution” credits for your own questions :wink:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.