mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
@@ -60,7 +60,14 @@ var allDecoderSetups = map[string]decodeWeight{
|
||||
key: "",
|
||||
weight: -100, // Always first.
|
||||
decode: func(d decodeWeight, p decodeConfig) error {
|
||||
return mapstructure.WeakDecode(p.p.Get(""), &p.c.RootConfig)
|
||||
if err := mapstructure.WeakDecode(p.p.Get(""), &p.c.RootConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// This need to match with Lang which is always lower case.
|
||||
p.c.RootConfig.DefaultContentLanguage = strings.ToLower(p.c.RootConfig.DefaultContentLanguage)
|
||||
|
||||
return nil
|
||||
},
|
||||
},
|
||||
"imaging": {
|
||||
@@ -263,6 +270,18 @@ var allDecoderSetups = map[string]decodeWeight{
|
||||
return err
|
||||
}
|
||||
|
||||
// Validate defaultContentLanguage.
|
||||
var found bool
|
||||
for lang := range p.c.Languages {
|
||||
if lang == p.c.DefaultContentLanguage {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return fmt.Errorf("config value %q for defaultContentLanguage does not match any language definition", p.c.DefaultContentLanguage)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user