summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-03-12 22:13:25 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-03-12 22:13:25 +0100
commit79dd7cb31a941d7545df33b938ca3ed46593ddfd (patch)
tree6c14532e8160e21d9239a2db6abba9ca49e68e6a /hugolib
parent0dbf79c2f8cd5b1a5c91c04a8d677f956b0b8fe8 (diff)
hugolib: Simplify Prev/Next
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/pagesPrevNext.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/hugolib/pagesPrevNext.go b/hugolib/pagesPrevNext.go
index bb474c499..947a49b85 100644
--- a/hugolib/pagesPrevNext.go
+++ b/hugolib/pagesPrevNext.go
@@ -16,8 +16,9 @@ package hugolib
// Prev returns the previous page reletive to the given page.
func (p Pages) Prev(cur *Page) *Page {
for x, c := range p {
- if c.UniqueID() == cur.UniqueID() {
+ if c.Eq(cur) {
if x == 0 {
+ // TODO(bep) consider return nil here to get it line with the other Prevs
return p[len(p)-1]
}
return p[x-1]
@@ -29,10 +30,11 @@ func (p Pages) Prev(cur *Page) *Page {
// Next returns the next page reletive to the given page.
func (p Pages) Next(cur *Page) *Page {
for x, c := range p {
- if c.UniqueID() == cur.UniqueID() {
+ if c.Eq(cur) {
if x < len(p)-1 {
return p[x+1]
}
+ // TODO(bep) consider return nil here to get it line with the other Nexts
return p[0]
}
}