mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-28 23:52:04 -05:00
parent
8290720107
commit
49fedbc51c
2 changed files with 93 additions and 55 deletions
|
@ -169,6 +169,9 @@ func (c *defaultConfigProvider) Set(k string, v interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
key, m := c.getNestedKeyAndMap(k, true)
|
key, m := c.getNestedKeyAndMap(k, true)
|
||||||
|
if m == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if existing, found := m[key]; found {
|
if existing, found := m[key]; found {
|
||||||
if p1, ok := existing.(maps.Params); ok {
|
if p1, ok := existing.(maps.Params); ok {
|
||||||
|
@ -289,6 +292,9 @@ func (c *defaultConfigProvider) Merge(k string, v interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
key, m := c.getNestedKeyAndMap(k, true)
|
key, m := c.getNestedKeyAndMap(k, true)
|
||||||
|
if m == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if existing, found := m[key]; found {
|
if existing, found := m[key]; found {
|
||||||
if p1, ok := existing.(maps.Params); ok {
|
if p1, ok := existing.(maps.Params); ok {
|
||||||
|
@ -422,7 +428,12 @@ func (c *defaultConfigProvider) getNestedKeyAndMap(key string, create bool) (str
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = next.(maps.Params)
|
var ok bool
|
||||||
|
current, ok = next.(maps.Params)
|
||||||
|
if !ok {
|
||||||
|
// E.g. a string, not a map that we can store values in.
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return parts[len(parts)-1], current
|
return parts[len(parts)-1], current
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,6 +576,7 @@ anchor = "smart"
|
||||||
quality = 75
|
quality = 75
|
||||||
`
|
`
|
||||||
|
|
||||||
|
newB := func(t testing.TB) *sitesBuilder {
|
||||||
b := newTestSitesBuilder(t).WithConfigFile("toml", baseConfig)
|
b := newTestSitesBuilder(t).WithConfigFile("toml", baseConfig)
|
||||||
|
|
||||||
b.WithSourceFile("themes/mytheme/config.toml", `
|
b.WithSourceFile("themes/mytheme/config.toml", `
|
||||||
|
@ -595,6 +596,13 @@ theme_param="themevalue2"
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Run("Variations", func(c *qt.C) {
|
||||||
|
|
||||||
|
b := newB(c)
|
||||||
|
|
||||||
b.WithEnviron(
|
b.WithEnviron(
|
||||||
"HUGO_ENVIRONMENT", "test",
|
"HUGO_ENVIRONMENT", "test",
|
||||||
"HUGO_NEW", "new", // key not in config.toml
|
"HUGO_NEW", "new", // key not in config.toml
|
||||||
|
@ -655,4 +663,23 @@ theme_param="themevalue2"
|
||||||
c.Assert(ofBase.MediaType, qt.Equals, media.TextType)
|
c.Assert(ofBase.MediaType, qt.Equals, media.TextType)
|
||||||
c.Assert(ofTheme.MediaType, qt.Equals, media.TextType)
|
c.Assert(ofTheme.MediaType, qt.Equals, media.TextType)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
// Issue #8709
|
||||||
|
c.Run("Set in string", func(c *qt.C) {
|
||||||
|
b := newB(c)
|
||||||
|
|
||||||
|
b.WithEnviron(
|
||||||
|
// imaging.anchor is a string, and it's not possible
|
||||||
|
// to set a child attribute.
|
||||||
|
"HUGO_IMAGING_ANCHOR_FOO", "top",
|
||||||
|
)
|
||||||
|
|
||||||
|
b.Build(BuildCfg{})
|
||||||
|
|
||||||
|
cfg := b.H.Cfg
|
||||||
|
c.Assert(cfg.Get("imaging.anchor"), qt.Equals, "smart")
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue