mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Fix language params handling
This fixes some issues with language params handling by separating params from configuration values per language. This means that you can now do this: ```toml [languages] [languages.en] languageName = "English" weight = 1 title = "My Cool Site" [languages.en.params] myParam = "Hi!" ``` This is not a breaking change, but the above is a less suprising way of configuring custom params. It also fixes some hard-to-debug corner-cases in multilingual sites. Fixes #4356 Fixes #4352
This commit is contained in:
@@ -111,10 +111,20 @@ func toSortedLanguages(cfg config.Provider, l map[string]interface{}) (helpers.L
|
||||
language.LanguageName = cast.ToString(v)
|
||||
case "weight":
|
||||
language.Weight = cast.ToInt(v)
|
||||
case "params":
|
||||
m := cast.ToStringMap(v)
|
||||
// Needed for case insensitive fetching of params values
|
||||
helpers.ToLowerMap(m)
|
||||
for k, vv := range m {
|
||||
language.SetParam(k, vv)
|
||||
}
|
||||
}
|
||||
|
||||
// Put all into the Params map
|
||||
language.SetParam(loki, v)
|
||||
|
||||
// Also set it in the configuration map (for baseURL etc.)
|
||||
language.Set(loki, v)
|
||||
}
|
||||
|
||||
langs[i] = language
|
||||
|
Reference in New Issue
Block a user