diff options
-rw-r--r-- | hugolib/content_map_page.go | 11 | ||||
-rw-r--r-- | hugolib/hugo_sites_build.go | 8 | ||||
-rw-r--r-- | hugolib/rebuild_test.go | 27 |
3 files changed, 46 insertions, 0 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index c51b4a17a..be834fbb6 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -1330,6 +1330,7 @@ func (h *HugoSites) resolveAndResetDependententPageOutputs(ctx context.Context, // This needs no reset, so no need to check it. return nil } + // First check the top level dependency manager. for _, id := range changes { checkedCounter.Add(1) @@ -1645,6 +1646,8 @@ func (sa *sitePagesAssembler) assembleTermsAndTranslations() error { views = sa.pageMap.cfg.taxonomyConfig.views ) + rebuild := sa.s.h.isRebuild() + lockType := doctree.LockTypeWrite w := &doctree.NodeShiftTreeWalker[contentNodeI]{ Tree: pages, @@ -1677,6 +1680,14 @@ func (sa *sitePagesAssembler) assembleTermsAndTranslations() error { pi := sa.Site.Conf.PathParser().Parse(files.ComponentFolderContent, viewTermKey+"/_index.md") term := pages.Get(pi.Base()) if term == nil { + if rebuild { + // A new tag was added in server mode. + taxonomy := pages.Get(viewName.pluralTreeKey) + if taxonomy != nil { + sa.assembleChanges.Add(taxonomy.GetIdentity()) + } + } + m := &pageMeta{ term: v, singular: viewName.singular, diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index ce4ca370c..ce8ddd143 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -324,6 +324,14 @@ func (h *HugoSites) assemble(ctx context.Context, l logg.LevelLogger, bcfg *Buil } } + // Handle new terms from assemblePagesStep2. + changes = bcfg.WhatChanged.Drain() + if len(changes) > 0 { + if err := h.resolveAndClearStateForIdentities(ctx, l, nil, changes); err != nil { + return err + } + } + h.renderFormats = output.Formats{} for _, s := range h.Sites { s.s.initRenderFormats() diff --git a/hugolib/rebuild_test.go b/hugolib/rebuild_test.go index 9d95a4b75..f5c0befcc 100644 --- a/hugolib/rebuild_test.go +++ b/hugolib/rebuild_test.go @@ -1865,3 +1865,30 @@ p1-content| b.EditFileReplaceAll("content/p1/index.md", "p1-content", "p1-content-foo").Build() b.AssertFileContent("public/p1/index.html", "p1-content-foo") } + +func TestRebuildEditTagIssue13648(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +disableLiveReload = true +-- layouts/all.html -- +All. {{ range .Pages }}{{ .Title }}|{{ end }} +-- content/p1.md -- +--- +title: "P1" +tags: ["tag1"] +--- + +` + b := TestRunning(t, files) + + b.AssertFileContent("public/tags/index.html", "All. Tag1|") + b.EditFileReplaceAll("content/p1.md", "tag1", "tag2").Build() + + // Note that the below is still not correct, as this is effectively a rename, and + // Tag2 should be removed from the list. + // But that is a harder problem to tackle. + b.AssertFileContent("public/tags/index.html", "All. Tag1|Tag2|") +} |