Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-10-11 12:09:43 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-10-13 13:36:17 +0300
commitf4f566edf4bd6a590cf9cdbd5cfc0026ecd93b14 (patch)
tree01545b36a279b80b5dbf732954e0bb41e73df5b5 /resources/page/pages_prev_next.go
parent7b3edc293144dd450e87ca32f238221c21eb1b47 (diff)
Make Pages.Prev/Next work like the other Prev/Next methods
Fixes #4500
Diffstat (limited to 'resources/page/pages_prev_next.go')
-rw-r--r--resources/page/pages_prev_next.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/resources/page/pages_prev_next.go b/resources/page/pages_prev_next.go
index 9293c9874..dd87aa4ce 100644
--- a/resources/page/pages_prev_next.go
+++ b/resources/page/pages_prev_next.go
@@ -13,13 +13,12 @@
package page
-// Prev returns the previous page reletive to the given
-func (p Pages) Prev(cur Page) Page {
+// Next returns the next page reletive to the given
+func (p Pages) Next(cur Page) Page {
for x, c := range p {
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 nil
}
return p[x-1]
}
@@ -27,15 +26,14 @@ func (p Pages) Prev(cur Page) Page {
return nil
}
-// Next returns the next page reletive to the given
-func (p Pages) Next(cur Page) Page {
+// Prev returns the previous page reletive to the given
+func (p Pages) Prev(cur Page) Page {
for x, c := range p {
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]
+ return nil
}
}
return nil