diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-10-16 19:28:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-16 19:28:21 +0200 |
commit | 40b1b8f70373dacf2458fbd9a67be32fc6830f91 (patch) | |
tree | fb03f4cde8daecd30c5e85c989a38a9fde5a2b3c /helpers/content.go | |
parent | 4d6cd3cb2aa46df781adde8debf9f64d50973365 (diff) |
Fix case issue Viper vs Blackfriday config
There are still work to be done in the case department, but that will have to be another day.
Fixes #2581
See https://github.com/spf13/viper/issues/261
Diffstat (limited to 'helpers/content.go')
-rw-r--r-- | helpers/content.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/helpers/content.go b/helpers/content.go index 516fc72b9..aa1327d74 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -27,7 +27,6 @@ import ( "github.com/miekg/mmark" "github.com/mitchellh/mapstructure" "github.com/russross/blackfriday" - "github.com/spf13/cast" bp "github.com/spf13/hugo/bufferpool" jww "github.com/spf13/jwalterweatherman" "github.com/spf13/viper" @@ -60,7 +59,8 @@ type Blackfriday struct { // NewBlackfriday creates a new Blackfriday filled with site config or some sane defaults. func NewBlackfriday(c ConfigProvider) *Blackfriday { - combinedParam := map[string]interface{}{ + + defaultParam := map[string]interface{}{ "smartypants": true, "angledQuotes": false, "fractions": true, @@ -73,17 +73,24 @@ func NewBlackfriday(c ConfigProvider) *Blackfriday { "sourceRelativeLinksProjectFolder": "/docs/content", } + ToLowerMap(defaultParam) + siteParam := c.GetStringMap("blackfriday") - if siteParam != nil { - siteConfig := cast.ToStringMap(siteParam) - for key, value := range siteConfig { - combinedParam[key] = value + siteConfig := make(map[string]interface{}) + + for k, v := range defaultParam { + siteConfig[k] = v + } + + if siteParam != nil { + for k, v := range siteParam { + siteConfig[k] = v } } combinedConfig := &Blackfriday{} - if err := mapstructure.Decode(combinedParam, combinedConfig); err != nil { + if err := mapstructure.Decode(siteConfig, combinedConfig); err != nil { jww.FATAL.Printf("Failed to get site rendering config\n%s", err.Error()) } |