hugolib: Introduce Page.NextPage and Page.PrevPage

Introduce new page position variables in order to fix the ordering issue
of `.Next` and `.Prev` while also allowing an upgrade path via
deprecation.

`.NextInSection` becomes `.NextPageInSection`.
`.PrevInSection` becomes `.PrevPageInSection`.

`.Next` becomes a function returning `.PrevPage`.
`.Prev` becomes a function returning `.NextPage`.

Fixes #1061
This commit is contained in:
Ricardo N Feliciano
2018-09-24 18:06:29 -04:00
committed by Bjørn Erik Pedersen
parent 52ac85fbc4
commit ad705aac06
4 changed files with 37 additions and 19 deletions

View File

@@ -505,8 +505,8 @@ type PageMeta struct {
}
type Position struct {
Prev *Page
Next *Page
PrevPage *Page
NextPage *Page
PrevInSection *Page
NextInSection *Page
}
@@ -2308,3 +2308,15 @@ func (p *Page) pathOrTitle() string {
}
return p.title
}
func (p *Page) Next() *Page {
// TODO Remove in Hugo 0.52
helpers.Deprecated("Page", ".Next", "Use .PrevPage (yes, not .NextPage).", false)
return p.PrevPage
}
func (p *Page) Prev() *Page {
// TODO Remove in Hugo 0.52
helpers.Deprecated("Page", ".Prev", "Use .NextPage (yes, not .PrevPage).", false)
return p.NextPage
}