mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-13 20:24:00 +02:00
@@ -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)
|
||||
|
Reference in New Issue
Block a user