diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-12-29 10:35:46 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-12-30 18:50:09 +0100 |
commit | 40ffb0484b96b7b77fb66202b33073b241807199 (patch) | |
tree | 6d9b9097b3adab78b3e07a257478d6e302944f1f /hugolib/hugo_sites.go | |
parent | 4bae8b04aadd72d298bf2dd1bb1430806bf2869c (diff) |
hugolib: Restore 0.48 slash handling in taxonomies
Fixes #5571
Diffstat (limited to 'hugolib/hugo_sites.go')
-rw-r--r-- | hugolib/hugo_sites.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index 6a4893473..9ce1c438e 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -548,7 +548,7 @@ func (h *HugoSites) createMissingPages() error { if s.isEnabled(KindTaxonomyTerm) { foundTaxonomyTermsPage := false for _, p := range taxonomyTermsPages { - if p.sections[0] == plural { + if p.sectionsPath() == plural { foundTaxonomyTermsPage = true break } @@ -570,11 +570,21 @@ func (h *HugoSites) createMissingPages() error { key = s.PathSpec.MakePathSanitized(key) } for _, p := range taxonomyPages { + sectionsPath := p.sectionsPath() + + if !strings.HasPrefix(sectionsPath, plural) { + continue + } + + singularKey := strings.TrimPrefix(sectionsPath, plural) + singularKey = strings.TrimPrefix(singularKey, "/") + // Some people may have /authors/MaxMustermann etc. as paths. // p.sections contains the raw values from the file system. // See https://github.com/gohugoio/hugo/issues/4238 - singularKey := s.PathSpec.MakePathSanitized(p.sections[1]) - if p.sections[0] == plural && singularKey == key { + singularKey = s.PathSpec.MakePathSanitized(singularKey) + + if singularKey == key { foundTaxonomyPage = true break } @@ -622,7 +632,7 @@ func (h *HugoSites) setupTranslations() { for _, s := range h.Sites { for _, p := range s.rawAllPages { if p.Kind == kindUnknown { - p.Kind = p.s.kindFromSections(p.sections) + p.Kind = p.kindFromSections() } if !p.s.isEnabled(p.Kind) { |