Add config options page.nextPrevSortOrder/nextPrevInSectionSortOrder

See #12776
This commit is contained in:
Bjørn Erik Pedersen
2024-08-17 15:16:09 +02:00
parent 53c0ddfcb4
commit 01008ba512
6 changed files with 132 additions and 1 deletions

View File

@@ -117,6 +117,9 @@ func (s *Site) prepareInits() {
s.init.prevNext = init.Branch(func(context.Context) (any, error) {
regularPages := s.RegularPages()
if s.conf.Page.NextPrevSortOrder == "asc" {
regularPages = regularPages.Reverse()
}
for i, p := range regularPages {
np, ok := p.(nextPrevProvider)
if !ok {
@@ -181,7 +184,11 @@ func (s *Site) prepareInits() {
)
for _, section := range sections {
setNextPrev(section.RegularPages())
ps := section.RegularPages()
if s.conf.Page.NextPrevInSectionSortOrder == "asc" {
ps = ps.Reverse()
}
setNextPrev(ps)
}
return nil, nil