diff --git a/common/paths/pathparser.go b/common/paths/pathparser.go index f506eb60f..eceb46b3d 100644 --- a/common/paths/pathparser.go +++ b/common/paths/pathparser.go @@ -480,6 +480,11 @@ func (p *Path) IsLeafBundle() bool { return p.bundleType == PathTypeLeaf } +func (p Path) ForBundleType(t PathType) *Path { + p.bundleType = t + return &p +} + func (p *Path) identifierAsString(i int) string { i = p.identifierIndex(i) if i == -1 { diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 75863acbd..43c67ce73 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -127,7 +127,22 @@ type pageTrees struct { // collectIdentities collects all identities from in all trees matching the given key. // This will at most match in one tree, but may give identies from multiple dimensions (e.g. language). -func (t *pageTrees) collectIdentities(key string) []identity.Identity { +func (t *pageTrees) collectIdentities(p *paths.Path) []identity.Identity { + ids := t.collectIdentitiesFor(p.Base()) + + if p.Component() == files.ComponentFolderContent { + // It may also be a bundled content resource. + if n := t.treeResources.Get(p.ForBundleType(paths.PathTypeContentResource).Base()); n != nil { + n.ForEeachIdentity(func(id identity.Identity) bool { + ids = append(ids, id) + return false + }) + } + } + return ids +} + +func (t *pageTrees) collectIdentitiesFor(key string) []identity.Identity { var ids []identity.Identity if n := t.treePages.Get(key); n != nil { n.ForEeachIdentity(func(id identity.Identity) bool { @@ -135,6 +150,7 @@ func (t *pageTrees) collectIdentities(key string) []identity.Identity { return false }) } + if n := t.treeResources.Get(key); n != nil { n.ForEeachIdentity(func(id identity.Identity) bool { ids = append(ids, id) diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index 4b22c1956..17af2d8d8 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -702,9 +702,7 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf switch pathInfo.Component() { case files.ComponentFolderContent: logger.Println("Source changed", pathInfo.Path()) - base := pathInfo.Base() - - if ids := h.pageTrees.collectIdentities(base); len(ids) > 0 { + if ids := h.pageTrees.collectIdentities(pathInfo); len(ids) > 0 { changes = append(changes, ids...) } @@ -723,7 +721,6 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf h.pageTrees.treeTaxonomyEntries.DeletePrefix("") if delete { - _, ok := h.pageTrees.treePages.LongestPrefixAll(pathInfo.Base()) if ok { h.pageTrees.treePages.DeleteAll(pathInfo.Base()) diff --git a/hugolib/pages_capture.go b/hugolib/pages_capture.go index b7da065fd..a7f8faaf0 100644 --- a/hugolib/pages_capture.go +++ b/hugolib/pages_capture.go @@ -196,6 +196,11 @@ func (c *pagesCollector) Collect() (collectErr error) { return id.p.Dir() == fim.Meta().PathInfo.Dir() } + + if fim.Meta().PathInfo.IsLeafBundle() && id.p.BundleType() == paths.PathTypeContentSingle { + return id.p.Dir() == fim.Meta().PathInfo.Dir() + } + return id.p.Path() == fim.Meta().PathInfo.Path() }) } diff --git a/hugolib/rebuild_test.go b/hugolib/rebuild_test.go index 74b04fe01..b1ebe14d5 100644 --- a/hugolib/rebuild_test.go +++ b/hugolib/rebuild_test.go @@ -39,7 +39,7 @@ My Section Bundle Text 2 Content. --- title: "My Section Bundle Content" --- -My Section Bundle Content. +My Section Bundle Content Content. -- content/mysection/_index.md -- --- title: "My Section" @@ -68,7 +68,7 @@ Foo. func TestRebuildEditTextFileInLeafBundle(t *testing.T) { b := TestRunning(t, rebuildFilesSimple) b.AssertFileContent("public/mysection/mysectionbundle/index.html", - "Resources: 0:/mysection/mysectionbundle/mysectionbundletext.txt|My Section Bundle Text 2 Content.|1:|

My Section Bundle Content.

\n|$") + "Resources: 0:/mysection/mysectionbundle/mysectionbundletext.txt|My Section Bundle Text 2 Content.|1:|

My Section Bundle Content Content.

\n|$") b.EditFileReplaceAll("content/mysection/mysectionbundle/mysectionbundletext.txt", "Content.", "Content Edited.").Build() b.AssertFileContent("public/mysection/mysectionbundle/index.html", @@ -109,6 +109,13 @@ func TestRebuildRenameTextFileInLeafBundle(t *testing.T) { b.AssertRenderCountContent(3) } +func TestRebuilEditContentFileInLeafBundle(t *testing.T) { + b := TestRunning(t, rebuildFilesSimple) + b.AssertFileContent("public/mysection/mysectionbundle/index.html", "My Section Bundle Content Content.") + b.EditFileReplaceAll("content/mysection/mysectionbundle/mysectionbundlecontent.md", "Content Content.", "Content Content Edited.").Build() + b.AssertFileContent("public/mysection/mysectionbundle/index.html", "My Section Bundle Content Content Edited.") +} + func TestRebuildRenameTextFileInBranchBundle(t *testing.T) { b := TestRunning(t, rebuildFilesSimple) b.AssertFileContent("public/mysection/index.html", "My Section")