Skip to content

Commit 39cf906

Browse files
committed
Fix mixed case Page params handling in content adapters
Fixes #12497
1 parent 1aacfce commit 39cf906

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

hugolib/pagesfromdata/pagesfromgotmpl_integration_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,27 @@ disableKinds = ['home','section','rss','sitemap','taxonomy','term']
494494

495495
b.AssertFileExists("public/s-1.2.3/p-4.5.6/index.html", true)
496496
}
497+
498+
func TestPagesFromGoParamsIssue12497(t *testing.T) {
499+
t.Parallel()
500+
501+
files := `
502+
-- hugo.toml --
503+
disableKinds = ['home','section','rss','sitemap','taxonomy','term']
504+
-- content/_content.gotmpl --
505+
{{ .AddPage (dict "path" "p1" "title" "p1" "params" (dict "paraM1" "param1v" )) }}
506+
{{ .AddResource (dict "path" "p1/data1.yaml" "content" (dict "value" "data1" ) "params" (dict "paraM1" "param1v" )) }}
507+
-- layouts/_default/single.html --
508+
{{ .Title }}|{{ .Params.paraM1 }}
509+
{{ range .Resources }}
510+
{{ .Name }}|{{ .Params.paraM1 }}
511+
{{ end }}
512+
`
513+
514+
b := hugolib.Test(t, files)
515+
516+
b.AssertFileContent("public/p1/index.html",
517+
"p1|param1v",
518+
"data1.yaml|param1v",
519+
)
520+
}

resources/page/pagemeta/page_frontmatter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ func (p *PageConfig) Compile(basePath string, pagesFromData bool, ext string, lo
151151
p.Path = path.Join(basePath, p.Path)
152152
}
153153

154+
if p.Params == nil {
155+
p.Params = make(maps.Params)
156+
}
157+
maps.PrepareParams(p.Params)
158+
154159
if p.Content.Markup == "" && p.Content.MediaType == "" {
155160
if ext == "" {
156161
ext = "md"

0 commit comments

Comments
 (0)