diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-04-02 11:53:43 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-04-02 14:32:05 +0200 |
commit | 983b8d537c6af7b9790dc8ab31817f066309d5bd (patch) | |
tree | b6556165e1f10df41267df947d49e2b18e50df77 /hugolib/content_map_page.go | |
parent | 6738a3e79dd545603d9851832bc3140fd184bfef (diff) | |
download | hugo-983b8d537c6af7b9790dc8ab31817f066309d5bd.tar.gz hugo-983b8d537c6af7b9790dc8ab31817f066309d5bd.zip |
Fix resource bundling for overlapping page.md vs page.txt
Fixes #12320
Diffstat (limited to 'hugolib/content_map_page.go')
-rw-r--r-- | hugolib/content_map_page.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 2f0a6408b..ff0b05ed1 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -489,12 +489,17 @@ func (m *pageMap) forEachResourceInPage( rw.Handle = func(resourceKey string, n contentNodeI, match doctree.DimensionFlag) (bool, error) { if isBranch { - ownerKey, _ := m.treePages.LongestPrefixAll(resourceKey) - if ownerKey != keyPage && path.Dir(ownerKey) != path.Dir(resourceKey) { + // A resourceKey always represents a filename with extension. + // 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). + // So, to avoid any overlapping ambiguity, we start looking from the owning directory. + ownerKey, _ := m.treePages.LongestPrefixAll(path.Dir(resourceKey)) + if ownerKey != keyPage { // Stop walking downwards, someone else owns this resource. rw.SkipPrefix(ownerKey + "/") return false, nil } + } return handle(resourceKey, n, match) } |