diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-04-22 20:43:00 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-04-22 20:43:18 +0200 |
commit | 10af906371bedb643f67d89ec370a1236c6504fd (patch) | |
tree | d01fdfde292db991ba1e6df57c1d144e0d26a739 /hugolib/pageSort.go | |
parent | fbca53ac325324db104df5de86add3fa0baf3488 (diff) |
Add ByLastmod page sort
Diffstat (limited to 'hugolib/pageSort.go')
-rw-r--r-- | hugolib/pageSort.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/hugolib/pageSort.go b/hugolib/pageSort.go index 7381cf9dd..40c18e4c6 100644 --- a/hugolib/pageSort.go +++ b/hugolib/pageSort.go @@ -158,6 +158,24 @@ func (p Pages) ByPublishDate() Pages { return pages } +// ByLastmod sorts the Pages by the last modification date and returns a copy. +// +// Adjacent invocactions on the same receiver will return a cached result. +// +// This may safely be executed in parallel. +func (p Pages) ByLastmod() Pages { + + key := "pageSort.ByLastmod" + + date := func(p1, p2 *Page) bool { + return p1.Lastmod.Unix() < p2.Lastmod.Unix() + } + + pages, _ := spc.get(key, p, pageBy(date).Sort) + + return pages +} + // ByLength sorts the Pages by length and returns a copy. // // Adjacent invocactions on the same receiver will return a cached result. |