mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
hugolib: Fix panic for unused taxonomy content files
In Hugo 0.55 we connected the taxonomy nodes with their owning Page. This failed if you had, say, a content file for a author that did not author anything in the site: ``` content/authors/silent-persin/_index.md ``` Fixes #5847
This commit is contained in:
@@ -94,7 +94,7 @@ type Site struct {
|
||||
|
||||
Taxonomies TaxonomyList
|
||||
|
||||
taxonomyNodes taxonomyNodeInfos
|
||||
taxonomyNodes *taxonomyNodeInfos
|
||||
|
||||
Sections Taxonomy
|
||||
Info SiteInfo
|
||||
@@ -1566,24 +1566,23 @@ func (s *Site) assembleTaxonomies() error {
|
||||
s.Taxonomies[plural] = make(Taxonomy)
|
||||
}
|
||||
|
||||
s.taxonomyNodes = make(taxonomyNodeInfos)
|
||||
s.taxonomyNodes = &taxonomyNodeInfos{
|
||||
m: make(map[string]*taxonomyNodeInfo),
|
||||
getKey: s.getTaxonomyKey,
|
||||
}
|
||||
|
||||
s.Log.INFO.Printf("found taxonomies: %#v\n", taxonomies)
|
||||
|
||||
for singular, plural := range taxonomies {
|
||||
parent := s.taxonomyNodes.GetOrCreate(plural, "", "")
|
||||
parent := s.taxonomyNodes.GetOrCreate(plural, "")
|
||||
parent.singular = singular
|
||||
|
||||
addTaxonomy := func(plural, term string, weight int, p page.Page) {
|
||||
key := s.getTaxonomyKey(term)
|
||||
|
||||
n := s.taxonomyNodes.GetOrCreate(plural, key, term)
|
||||
n := s.taxonomyNodes.GetOrCreate(plural, term)
|
||||
n.parent = parent
|
||||
|
||||
// There may be different spellings before normalization, so the
|
||||
// last one will win, e.g. "hugo" vs "Hugo".
|
||||
n.term = term
|
||||
|
||||
w := page.NewWeightedPage(weight, p, n.owner)
|
||||
|
||||
s.Taxonomies[plural].add(key, w)
|
||||
|
Reference in New Issue
Block a user