summaryrefslogtreecommitdiffstats
path: root/hugolib/site.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-04-15 09:38:14 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-04-15 13:36:05 +0200
commitb799b12f4a693dfeae8a5a362f131081a727bb8f (patch)
treecec0b90c41aea0f091ac5aa8dc72fc7380f78253 /hugolib/site.go
parent701486728e21bc0c6c78c2a8edb988abdf6116c7 (diff)
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
Diffstat (limited to 'hugolib/site.go')
-rw-r--r--hugolib/site.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/hugolib/site.go b/hugolib/site.go
index 2653479ea..47ca77016 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -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)