diff options
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | config/allconfig/allconfig_integration_test.go | 22 | ||||
-rw-r--r-- | config/allconfig/load.go | 55 | ||||
-rw-r--r-- | hugoreleaser.env | 5 | ||||
-rw-r--r-- | tpl/tplimpl/embedded/templates/_shortcodes/twitter.html | 2 | ||||
-rw-r--r-- | tpl/tplimpl/embedded/templates/_shortcodes/vimeo.html | 2 | ||||
-rw-r--r-- | tpl/tplimpl/embedded/templates/_shortcodes/x.html | 2 | ||||
-rw-r--r-- | tpl/tplimpl/shortcodes_integration_test.go | 1 |
8 files changed, 65 insertions, 30 deletions
@@ -65,9 +65,11 @@ See the [features] section of the documentation for a comprehensive summary of H <p> </p> <p float="left"> - <a href="https://www.linode.com/?utm_campaign=hugosponsor&utm_medium=banner&utm_source=hugogithub" target="_blank"><img src="https://raw.githubusercontent.com/gohugoio/gohugoioTheme/master/assets/images/sponsors/linode-logo_standard_light_medium.png" width="200" alt="Linode"></a> + <a href="https://www.linode.com/?utm_campaign=hugosponsor&utm_medium=banner&utm_source=hugogithub" target="_blank"><img src="https://raw.githubusercontent.com/gohugoio/hugoDocs/master/assets/images/sponsors/linode-logo_standard_light_medium.png" width="200" alt="Linode"></a> - <a href="https://www.jetbrains.com/go/?utm_source=OSS&utm_medium=referral&utm_campaign=hugo" target="_blank"><img src="https://raw.githubusercontent.com/gohugoio/gohugoioTheme/master/assets/images/sponsors/goland.svg" width="200" alt="The complete IDE crafted for professional Go developers."></a> + <a href="https://www.jetbrains.com/go/?utm_source=OSS&utm_medium=referral&utm_campaign=hugo" target="_blank"><img src="https://raw.githubusercontent.com/gohugoio/hugoDocs/master/assets/images/sponsors/goland.svg" width="200" alt="The complete IDE crafted for professional Go developers."></a> + + <a href="https://pinme.eth.limo/?s=hugo" target="_blank"><img src="https://raw.githubusercontent.com/gohugoio/hugoDocs/master/assets/images/sponsors/logo-pinme.svg" width="200" alt="PinMe."></a> </p> ## Editions diff --git a/config/allconfig/allconfig_integration_test.go b/config/allconfig/allconfig_integration_test.go index f8fbb22f7..8f6cacf84 100644 --- a/config/allconfig/allconfig_integration_test.go +++ b/config/allconfig/allconfig_integration_test.go @@ -357,3 +357,25 @@ All. b.Assert(b.H.Conf.DefaultContentLanguage(), qt.Equals, "sv") } + +func TestDefaultConfigEnvDisableLanguagesIssue13707(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +disableLanguages = [] +[languages] +[languages.en] +weight = 1 +[languages.nn] +weight = 2 +[languages.sv] +weight = 3 +` + + b := hugolib.Test(t, files, hugolib.TestOptWithConfig(func(conf *hugolib.IntegrationTestConfig) { + conf.Environ = []string{`HUGO_DISABLELANGUAGES=sv nn`} + })) + + b.Assert(len(b.H.Sites), qt.Equals, 1) +} diff --git a/config/allconfig/load.go b/config/allconfig/load.go index 2d9185f6f..4fb8bbaef 100644 --- a/config/allconfig/load.go +++ b/config/allconfig/load.go @@ -233,40 +233,51 @@ func (l configLoader) applyOsEnvOverrides(environ []string) error { if existing != nil { val, err := metadecoders.Default.UnmarshalStringTo(env.Value, existing) - if err != nil { + if err == nil { + val = l.envValToVal(env.Key, val) + if owner != nil { + owner[nestedKey] = val + } else { + l.cfg.Set(env.Key, val) + } continue } + } - if owner != nil { - owner[nestedKey] = val - } else { - l.cfg.Set(env.Key, val) - } + if owner != nil && nestedKey != "" { + owner[nestedKey] = env.Value } else { - if nestedKey != "" { - owner[nestedKey] = env.Value - } else { - var val any - key := strings.ReplaceAll(env.Key, delim, ".") - _, ok := allDecoderSetups[key] - if ok { - // A map. - if v, err := metadecoders.Default.UnmarshalStringTo(env.Value, map[string]any{}); err == nil { - val = v - } + var val any + key := strings.ReplaceAll(env.Key, delim, ".") + _, ok := allDecoderSetups[key] + if ok { + // A map. + if v, err := metadecoders.Default.UnmarshalStringTo(env.Value, map[string]any{}); err == nil { + val = v } - if val == nil { - // A string. - val = l.envStringToVal(key, env.Value) - } - l.cfg.Set(key, val) } + + if val == nil { + // A string. + val = l.envStringToVal(key, env.Value) + } + l.cfg.Set(key, val) } + } return nil } +func (l *configLoader) envValToVal(k string, v any) any { + switch v := v.(type) { + case string: + return l.envStringToVal(k, v) + default: + return v + } +} + func (l *configLoader) envStringToVal(k, v string) any { switch k { case "disablekinds", "disablelanguages": diff --git a/hugoreleaser.env b/hugoreleaser.env index 5d373cd71..82c1a31e7 100644 --- a/hugoreleaser.env +++ b/hugoreleaser.env @@ -1,7 +1,8 @@ # Release env. # These will be replaced by script before release. -HUGORELEASER_TAG=v0.147.2 -HUGORELEASER_COMMITISH=c7feb15d10b29a94d7fb57c31e8bcb2e92718fb7 +HUGORELEASER_TAG=v0.147.3 +HUGORELEASER_COMMITISH=05417512bd001c0b2cc0042dcc584575825b89b3 + diff --git a/tpl/tplimpl/embedded/templates/_shortcodes/twitter.html b/tpl/tplimpl/embedded/templates/_shortcodes/twitter.html index ce356559d..849bad99e 100644 --- a/tpl/tplimpl/embedded/templates/_shortcodes/twitter.html +++ b/tpl/tplimpl/embedded/templates/_shortcodes/twitter.html @@ -2,7 +2,7 @@ {{- $pc := site.Config.Privacy.Twitter -}} {{- if not $pc.Disable -}} {{- if $pc.Simple -}} - {{- template "_internal/shortcodes/twitter_simple.html" . -}} + {{- template "_shortcodes/twitter_simple.html" . -}} {{- else -}} {{- $id := or (.Get "id") "" -}} {{- $user := or (.Get "user") "" -}} diff --git a/tpl/tplimpl/embedded/templates/_shortcodes/vimeo.html b/tpl/tplimpl/embedded/templates/_shortcodes/vimeo.html index 2588ac86c..fb8ea0d97 100644 --- a/tpl/tplimpl/embedded/templates/_shortcodes/vimeo.html +++ b/tpl/tplimpl/embedded/templates/_shortcodes/vimeo.html @@ -18,7 +18,7 @@ title, then loading. {{- $pc := site.Config.Privacy.Vimeo }} {{- if not $pc.Disable }} {{- if $pc.Simple }} - {{- template "_internal/shortcodes/vimeo_simple.html" . }} + {{- template "_shortcodes/vimeo_simple.html" . }} {{- else }} {{- $dnt := cond $pc.EnableDNT 1 0 }} diff --git a/tpl/tplimpl/embedded/templates/_shortcodes/x.html b/tpl/tplimpl/embedded/templates/_shortcodes/x.html index 28a5e331b..87455530c 100644 --- a/tpl/tplimpl/embedded/templates/_shortcodes/x.html +++ b/tpl/tplimpl/embedded/templates/_shortcodes/x.html @@ -1,7 +1,7 @@ {{- $pc := site.Config.Privacy.X -}} {{- if not $pc.Disable -}} {{- if $pc.Simple -}} - {{- template "_internal/shortcodes/x_simple.html" . -}} + {{- template "_shortcodes/x_simple.html" . -}} {{- else -}} {{- $id := or (.Get "id") "" -}} {{- $user := or (.Get "user") "" -}} diff --git a/tpl/tplimpl/shortcodes_integration_test.go b/tpl/tplimpl/shortcodes_integration_test.go index 665760dec..838dc16d7 100644 --- a/tpl/tplimpl/shortcodes_integration_test.go +++ b/tpl/tplimpl/shortcodes_integration_test.go @@ -460,7 +460,6 @@ title: p1 (de) } func TestVimeoShortcode(t *testing.T) { - t.Skip("Fix me: Upstream API changes") t.Parallel() files := ` |