summaryrefslogtreecommitdiffstats
path: root/hugolib/site.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-12-13 11:52:26 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-12-14 10:29:32 +0100
commit9ce0a1fb7011bd75eb0e2262e35354c49ce98ac5 (patch)
treec3ff6ae598ec5dcf022c05b8b076e93922caafb3 /hugolib/site.go
parentab9214768de4ce10032d3fe7ec8c7b2932ead892 (diff)
hugolib: Restore taxonomy term path separation
Fixes #5513
Diffstat (limited to 'hugolib/site.go')
-rw-r--r--hugolib/site.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/hugolib/site.go b/hugolib/site.go
index 7882d517f..cf8b3a28d 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -22,6 +22,7 @@ import (
"mime"
"net/url"
"os"
+ "path"
"path/filepath"
"sort"
"strconv"
@@ -1586,11 +1587,28 @@ func (s *Site) resetBuildState() {
}
}
+func (s *Site) singularPluralAll(sections []string) (string, string, string) {
+ slen := len(sections)
+ singular := sections[slen-1]
+ plural := path.Join((sections[:slen-1])...)
+ all := path.Join(sections...)
+
+ return singular, plural, all
+}
+
func (s *Site) kindFromSections(sections []string) string {
if len(sections) == 0 {
return KindSection
}
+ _, plural, all := s.singularPluralAll(sections)
+
+ if _, ok := s.Taxonomies[all]; ok {
+ return KindTaxonomyTerm
+ } else if _, ok := s.Taxonomies[plural]; ok {
+ return KindTaxonomy
+ }
+
if _, isTaxonomy := s.Taxonomies[sections[0]]; isTaxonomy {
if len(sections) == 1 {
return KindTaxonomyTerm
@@ -1876,8 +1894,10 @@ func (s *Site) newHomePage() *Page {
}
func (s *Site) newTaxonomyPage(plural, key string) *Page {
+ sections := strings.Split(plural, "/")
+ sections = append(sections, key)
- p := s.newNodePage(KindTaxonomy, plural, key)
+ p := s.newNodePage(KindTaxonomy, sections...)
if s.Info.preserveTaxonomyNames {
p.title = key
@@ -1901,7 +1921,7 @@ func (s *Site) newSectionPage(name string) *Page {
}
func (s *Site) newTaxonomyTermsPage(plural string) *Page {
- p := s.newNodePage(KindTaxonomyTerm, plural)
+ p := s.newNodePage(KindTaxonomyTerm, strings.Split(plural, "/")...)
p.title = s.titleFunc(plural)
return p
}