summaryrefslogtreecommitdiffstats
path: root/hugolib/page.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-05-21 11:25:00 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-05-24 12:35:45 +0200
commita985efcecf44afe1d252690ec0a00cf077974f44 (patch)
tree792e19ede943310f091977edb36962d1eee596f9 /hugolib/page.go
parent6c3c6686f5d3c7155e2d455b07ac8ab70f42cb88 (diff)
Fix GetPage on section/bundle name overlaps
In the internal Radix we stored the directory based nodes without a traling slash, e.g. `/blog`. The original motivation was probably to make it easy to do prefix searching: Give me all ancestors. This, however have lead to some ambigouty with overlapping directory names. This particular problem was, however, not possible to work around in an easy way, so from now we store these as `/blog/`. Fixes #7301
Diffstat (limited to 'hugolib/page.go')
-rw-r--r--hugolib/page.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/hugolib/page.go b/hugolib/page.go
index bd518c1e1..dbcc31236 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -133,22 +133,21 @@ func (p *pageState) GitInfo() *gitmap.GitInfo {
// GetTerms gets the terms defined on this page in the given taxonomy.
func (p *pageState) GetTerms(taxonomy string) page.Pages {
- taxonomy = strings.ToLower(taxonomy)
+ if p.treeRef == nil {
+ return nil
+ }
+
m := p.s.pageMap
- prefix := cleanTreeKey(taxonomy)
- var self string
- if p.IsHome() {
- // TODO(bep) make this less magical, see taxonomyEntries.Insert.
- self = "/" + page.KindHome
- } else if p.treeRef != nil {
- self = p.treeRef.key
- }
+ taxonomy = strings.ToLower(taxonomy)
+ prefix := cleanSectionTreeKey(taxonomy)
+ self := strings.TrimPrefix(p.treeRef.key, "/")
var pas page.Pages
m.taxonomies.WalkQuery(pageMapQuery{Prefix: prefix}, func(s string, n *contentNode) bool {
- if _, found := m.taxonomyEntries.Get(s + self); found {
+ key := s + self
+ if _, found := m.taxonomyEntries.Get(key); found {
pas = append(pas, n.p)
}
return false