Avoid panic in invalid language config

Fixes #11046
This commit is contained in:
Bjørn Erik Pedersen
2023-05-30 11:48:17 +02:00
parent a7d6b1413f
commit 6462eecfbd
3 changed files with 60 additions and 16 deletions

View File

@@ -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
}