parent
61d3d20129
commit
c5a63a3b4f
2 changed files with 46 additions and 2 deletions
|
@ -509,8 +509,23 @@ func (m *pageMap) forEachResourceInPage(
|
||||||
// A page key points to the logical path of a page, which when sourced from the filesystem
|
// A page key points to the logical path of a page, which when sourced from the filesystem
|
||||||
// may represent a directory (bundles) or a single content file (e.g. p1.md).
|
// may represent a directory (bundles) or a single content file (e.g. p1.md).
|
||||||
// So, to avoid any overlapping ambiguity, we start looking from the owning directory.
|
// So, to avoid any overlapping ambiguity, we start looking from the owning directory.
|
||||||
ownerKey, _ := m.treePages.LongestPrefixAll(path.Dir(resourceKey))
|
s := resourceKey
|
||||||
if ownerKey != keyPage {
|
|
||||||
|
for {
|
||||||
|
s = path.Dir(s)
|
||||||
|
ownerKey, found := m.treePages.LongestPrefixAll(s)
|
||||||
|
if !found {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
if ownerKey == keyPage {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if s != ownerKey && strings.HasPrefix(s, ownerKey) {
|
||||||
|
// Keep looking
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Stop walking downwards, someone else owns this resource.
|
// Stop walking downwards, someone else owns this resource.
|
||||||
rw.SkipPrefix(ownerKey + "/")
|
rw.SkipPrefix(ownerKey + "/")
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
|
@ -361,6 +361,35 @@ p1-foo.txt
|
||||||
b.AssertFileExists("public/s1/p1/index.html", true)
|
b.AssertFileExists("public/s1/p1/index.html", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 13228.
|
||||||
|
func TestBranchResourceOverlap(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
|
||||||
|
-- content/_index.md --
|
||||||
|
---
|
||||||
|
title: home
|
||||||
|
---
|
||||||
|
-- content/s1/_index.md --
|
||||||
|
---
|
||||||
|
title: s1
|
||||||
|
---
|
||||||
|
-- content/s1x/a.txt --
|
||||||
|
a.txt
|
||||||
|
-- layouts/index.html --
|
||||||
|
Home.
|
||||||
|
{{ range .Resources.Match "**" }}
|
||||||
|
{{ .Name }}|
|
||||||
|
{{ end }}
|
||||||
|
`
|
||||||
|
|
||||||
|
b := Test(t, files)
|
||||||
|
|
||||||
|
b.AssertFileContent("public/index.html", "s1x/a.txt|")
|
||||||
|
}
|
||||||
|
|
||||||
func TestSitemapOverrideFilename(t *testing.T) {
|
func TestSitemapOverrideFilename(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue