diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-30 11:48:17 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-30 15:59:43 +0200 |
commit | 6462eecfbd7abc14fa62b33bb079ba424de7d765 (patch) | |
tree | dbcff5292acb8920c5d5a9f3bdf356bdf33a7c3a /langs | |
parent | a7d6b1413f7dd7fdda30b12d577b90f4bb0487ff (diff) |
Avoid panic in invalid language config
Fixes #11046
Diffstat (limited to 'langs')
-rw-r--r-- | langs/config.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/langs/config.go b/langs/config.go index 15c0bedbc..f60ea94a4 100644 --- a/langs/config.go +++ b/langs/config.go @@ -14,6 +14,8 @@ package langs import ( + "errors" + "github.com/gohugoio/hugo/common/maps" "github.com/mitchellh/mapstructure" ) @@ -46,5 +48,8 @@ func DecodeConfig(m map[string]any) (map[string]LanguageConfig, error) { if err := mapstructure.WeakDecode(m, &langs); err != nil { return nil, err } + if len(langs) == 0 { + return nil, errors.New("no languages configured") + } return langs, nil } |