Fix panic when 404 is backed by a content file

Fixes #14283
This commit is contained in:
Bjørn Erik Pedersen
2025-12-20 11:26:33 +01:00
parent 5f46da6e2a
commit f740d7cfe0
3 changed files with 23 additions and 1 deletions
+21
View File
@@ -92,3 +92,24 @@ Not found.
b.AssertFileContent("public/404.html", `Not found. Updated.`)
}
func Test404Panic14283(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
baseURL = "http://example.com/"
-- layouts/all.html --
All. {{ .Kind }}. {{ .Title }}|
-- content/404/_index.md --
---
title: "404 branch"
---
This is the 404 branch.
`
b := Test(t, files) // panic.
b.AssertFileContent("public/404/index.html", "All. section. 404 branch|")
}
+1
View File
@@ -198,6 +198,7 @@ func (a *allPagesAssembler) doCreatePages(prefix string, depth int) error {
p := newHomePageMetaSource()
treePages.InsertRaw(p.pathInfo.Base(), p)
}
}
getCascades := func(wctx *doctree.WalkContext[contentNode], s string) *page.PageMatcherParamsConfigs {
+1 -1
View File
@@ -625,7 +625,7 @@ func (r *NodeShiftTreeWalker[T]) toT(tree *NodeShiftTree[T], v T) (T, bool) {
}
func (r *NodeShiftTree[T]) Has(s string) bool {
_, ok := r.get(s)
_, ok := r.GetRaw(s)
return ok
}