Skip to content

Commit

Permalink
Fix handling of draft term pages
Browse files Browse the repository at this point in the history
By just removing the term page and all of its page entries.

Fixes #12055
  • Loading branch information
bep committed Feb 17, 2024
1 parent 9cc6575 commit fc6aabe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hugolib/content_map_page.go
Expand Up @@ -1415,8 +1415,10 @@ func (sa *sitePagesAssembler) applyAggregatesToTaxonomiesAndTerms() error {
if err := p.setMetaPost(cascade); err != nil {
return false, err
}

if err := sa.pageMap.treeTaxonomyEntries.WalkPrefix(
if !p.s.shouldBuild(p) {
sa.pageMap.treePages.Delete(s)
sa.pageMap.treeTaxonomyEntries.DeletePrefix(paths.AddTrailingSlash(s))
} else if err := sa.pageMap.treeTaxonomyEntries.WalkPrefix(
doctree.LockTypeRead,
paths.AddTrailingSlash(s),
func(ss string, wn *weightedContentNode) (bool, error) {
Expand Down
23 changes: 23 additions & 0 deletions hugolib/taxonomy_test.go
Expand Up @@ -835,3 +835,26 @@ tags: ["hellO world"]

b.AssertFileContent("public/tags/hello-world/index.html", "HellO World|term|tag|tags|hellO world|")
}

func TestTermDraft(t *testing.T) {
t.Parallel()

files := `
-- layouts/_default/list.html --
|{{ .Title }}|
-- content/p1.md --
---
title: p1
tags: [a]
---
-- content/tags/a/_index.md --
---
title: tag-a-title-override
draft: true
---
`

b := Test(t, files)

b.AssertFileExists("public/tags/a/index.html", false)
}

0 comments on commit fc6aabe

Please sign in to comment.