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:
Bjørn Erik Pedersen
2019-04-15 09:38:14 +02:00
parent 701486728e
commit b799b12f4a
5 changed files with 52 additions and 17 deletions

View File

@@ -746,8 +746,10 @@ func (p *pageState) getTaxonomyNodeInfo() *taxonomyNodeInfo {
info := p.s.taxonomyNodes.Get(p.SectionsEntries()...)
if info == nil {
// This should never happpen
panic(fmt.Sprintf("invalid taxonomy state for %q with sections %v", p.pathOrTitle(), p.SectionsEntries()))
// There can be unused content pages for taxonomies (e.g. author that
// has not written anything, yet), and these will not have a taxonomy
// node created in the assemble taxonomies step.
return nil
}
return info