mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Fix WeightedPages in union etc.
We introduced a callback func() to get the owner Page in 0.55.0. Sadly, funcs is not comparable type in Go. This commit replaces the func with a struct pointer that wraps the Page. Fixes #5850
This commit is contained in:
@@ -175,7 +175,7 @@ type taxonomyNodeInfo struct {
|
||||
parent *taxonomyNodeInfo
|
||||
|
||||
// Either of Kind taxonomyTerm (parent) or taxonomy
|
||||
owner page.Page
|
||||
owner *page.PageWrapper
|
||||
}
|
||||
|
||||
func (t *taxonomyNodeInfo) UpdateFromPage(p page.Page) {
|
||||
@@ -185,17 +185,12 @@ func (t *taxonomyNodeInfo) UpdateFromPage(p page.Page) {
|
||||
}
|
||||
|
||||
func (t *taxonomyNodeInfo) TransferValues(p *pageState) {
|
||||
t.owner = p
|
||||
t.owner.Page = p
|
||||
if p.Lastmod().IsZero() && p.Date().IsZero() {
|
||||
p.m.Dates.UpdateDateAndLastmodIfAfter(t.dates)
|
||||
}
|
||||
}
|
||||
|
||||
// callback sent to the child nodes.
|
||||
func (t *taxonomyNodeInfo) getOwner() page.Page {
|
||||
return t.owner
|
||||
}
|
||||
|
||||
// Maps either plural or plural/term to a taxonomy node.
|
||||
// TODO(bep) consolidate somehow with s.Taxonomies
|
||||
type taxonomyNodeInfos map[string]*taxonomyNodeInfo
|
||||
@@ -216,6 +211,7 @@ func (t taxonomyNodeInfos) GetOrCreate(plural, termKey, term string) *taxonomyNo
|
||||
plural: plural,
|
||||
termKey: termKey,
|
||||
term: term,
|
||||
owner: &page.PageWrapper{}, // Page will be assigned later.
|
||||
}
|
||||
|
||||
t[key] = n
|
||||
|
Reference in New Issue
Block a user