mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-01 08:00:05 +03:00
Fix it so the owning taxonomy gets rerendered in server when new tags are added
Some checks failed
Some checks failed
Updates #13648
This commit is contained in:
parent
673a4d00eb
commit
a1cb15e1cf
3 changed files with 46 additions and 0 deletions
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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|")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue