mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Fix Viperized .Site.Params
git bisect identified 62dd1d4
as the breaking commit; when
github.com/spf13/viper was introduced, the Params field was always
empty.
Given a map in YAML in Viper, the return type is
`map[interface{}]interface{}`, _not_ `map[string]interface{}`, even if
`.SetDefault()` has been called with an item of
`map[string]interface{}{}` so the cast assertion on the `.Get("Params")`
always failed.
This commit is contained in:
parent
e98f0014f2
commit
280df4e380
1 changed files with 10 additions and 2 deletions
|
@ -260,9 +260,17 @@ func (s *Site) initialize() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) initializeSiteInfo() {
|
func (s *Site) initializeSiteInfo() {
|
||||||
params, ok := viper.Get("Params").(map[string]interface{})
|
paramsV, ok := viper.Get("Params").(map[interface{}]interface{})
|
||||||
|
// Warning: viper.Get(map_item) returns map[interface{}]interface{}
|
||||||
|
// even if .SetDefault called with a map[string]interface{}
|
||||||
if !ok {
|
if !ok {
|
||||||
params = make(map[string]interface{})
|
paramsV = make(map[interface{}]interface{})
|
||||||
|
}
|
||||||
|
params := make(map[string]interface{}, len(paramsV))
|
||||||
|
for k, v := range paramsV {
|
||||||
|
if s, ok := k.(string); ok {
|
||||||
|
params[s] = v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
permalinks := make(PermalinkOverrides)
|
permalinks := make(PermalinkOverrides)
|
||||||
|
|
Loading…
Reference in a new issue