Hey everyone,
I’ve been evaluating Hugo over the last week and started development of a theme to help in learning it. I came across a particular feature I’d like to see (Page.NextInPages, much like NextInSection) following this rationale:
When a paginator is created, I am free to pass to the paginator any sorted list of pages. This sorted list is then inaccessible in a single page’s template, making “newer” and “older” page links broken, unless I rely on the default “publishdate” parameters of pages. However, I am using a post-receive git hook to automatically rebuild the site and publish it with every new content commit. Since the Git backend uses the “lastmod” parameter, I would like to have some means of utilizing Page.Next and Page.Prev that utilizes the “lastmod” parameter.
e.g.
$paginator := .Paginate (where .Data.Pages.ByLastmod.Reverse “Section” .Section)
I thought to generalize this into a more accessible mechanism that would have use cases beyond my own, and it occurred to me that it would be pretty useful for pages to see their next/prev page according to the sort mechanism provided to the paginator. Otherwise, paginated pages have pretty random results with .NextInSection, et al.
So I forked it, and added it, which you can see here:
I am currently using this modified version for my own site, but if anyone thinks it would be useful I’d be happy to push the “pull request” button. I don’t really use github very much though, so you’ll have to forgive me if I’m doing something hu/gouache/.