diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-07-27 13:00:01 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-07-27 15:51:25 +0200 |
commit | 7f058b8bab947db98939ed27a7c2a08468323d08 (patch) | |
tree | c3af23c64a0b11ad2687e34f984608710a5f4632 /config | |
parent | 575d7f8068082bf75ee4939fafa186c796a06a0c (diff) | |
download | hugo-7f058b8bab947db98939ed27a7c2a08468323d08.tar.gz hugo-7f058b8bab947db98939ed27a7c2a08468323d08.zip |
Fix multiple languages in HUGO_DISABLELANGUAGES
Fixes #11278
Diffstat (limited to 'config')
-rw-r--r-- | config/allconfig/load.go | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/config/allconfig/load.go b/config/allconfig/load.go index 8551039a0..91cf1eb05 100644 --- a/config/allconfig/load.go +++ b/config/allconfig/load.go @@ -297,14 +297,20 @@ func (l configLoader) applyOsEnvOverrides(environ []string) error { if nestedKey != "" { owner[nestedKey] = env.Value } else { - var val any = env.Value - if _, ok := allDecoderSetups[env.Key]; ok { + var val any + key := strings.ReplaceAll(env.Key, delim, ".") + _, ok := allDecoderSetups[key] + if ok { // A map. - val, err = metadecoders.Default.UnmarshalStringTo(env.Value, map[string]interface{}{}) + if v, err := metadecoders.Default.UnmarshalStringTo(env.Value, map[string]interface{}{}); err == nil { + val = v + } } - if err == nil { - l.cfg.Set(strings.ReplaceAll(env.Key, delim, "."), val) + if val == nil { + // A string. + val = l.envStringToVal(key, env.Value) } + l.cfg.Set(key, val) } } } @@ -312,6 +318,20 @@ func (l configLoader) applyOsEnvOverrides(environ []string) error { return nil } +func (l *configLoader) envStringToVal(k, v string) any { + switch k { + case "disablekinds", "disablelanguages": + if strings.Contains(v, ",") { + return strings.Split(v, ",") + } else { + return strings.Fields(v) + } + default: + return v + } + +} + func (l *configLoader) loadConfigMain(d ConfigSourceDescriptor) (config.LoadConfigResult, modules.ModulesConfig, error) { var res config.LoadConfigResult |