mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
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:
committed by
Bjørn Erik Pedersen
parent
52ac85fbc4
commit
ad705aac06
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user