mirror of
https://github.com/gohugoio/hugo.git
synced 2025-06-28 11:49:52 +00:00
parent
18a9ca7d7a
commit
36f6f987a9
2 changed files with 6 additions and 4 deletions
|
@ -174,6 +174,9 @@ func DecodeCascade(logger loggers.Logger, handleLegacyFormat bool, in any) (*map
|
|||
|
||||
func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, error) {
|
||||
var pcfg PageMatcherParamsConfig
|
||||
if pcfg.Fields == nil {
|
||||
pcfg.Fields = make(maps.Params)
|
||||
}
|
||||
for k, v := range m {
|
||||
switch strings.ToLower(k) {
|
||||
case "_target", "target":
|
||||
|
@ -193,9 +196,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
|||
}
|
||||
}
|
||||
default:
|
||||
if pcfg.Fields == nil {
|
||||
pcfg.Fields = make(maps.Params)
|
||||
}
|
||||
|
||||
pcfg.Fields[k] = v
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ func TestPageMatcher(t *testing.T) {
|
|||
Params: maps.Params{
|
||||
"foo": "bar",
|
||||
},
|
||||
Fields: maps.Params{},
|
||||
Target: PageMatcher{Path: "", Kind: "page", Lang: "", Environment: ""},
|
||||
})
|
||||
})
|
||||
|
@ -136,9 +137,10 @@ func TestDecodeCascadeConfig(t *testing.T) {
|
|||
c.Assert(got.SourceStructure, qt.DeepEquals, []PageMatcherParamsConfig{
|
||||
{
|
||||
Params: maps.Params{"a": string("av")},
|
||||
Fields: maps.Params{},
|
||||
Target: PageMatcher{Kind: "page", Environment: "production"},
|
||||
},
|
||||
{Params: maps.Params{"b": string("bv")}, Target: PageMatcher{Kind: "page"}},
|
||||
{Params: maps.Params{"b": string("bv")}, Fields: maps.Params{}, Target: PageMatcher{Kind: "page"}},
|
||||
})
|
||||
|
||||
got, err = DecodeCascadeConfig(loggers.NewDefault(), true, nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue