Prevent site config being overwritten

Fixed #867
This commit is contained in:
bep 2015-01-31 19:14:13 +01:00
parent 659f71e617
commit 47c8f32967

View file

@ -199,14 +199,20 @@ func (p *Page) getRenderingConfig() *helpers.Blackfriday {
pageParam := p.GetParam("blackfriday")
siteParam := viper.GetStringMap("blackfriday")
combinedParam := make(map[string]interface{})
for k, v := range siteParam {
combinedParam[k] = v
}
if pageParam != nil {
pageConfig := cast.ToStringMap(pageParam)
for key, value := range pageConfig {
siteParam[key] = value
combinedParam[key] = value
}
}
p.renderingConfig = new(helpers.Blackfriday)
if err := mapstructure.Decode(siteParam, p.renderingConfig); err != nil {
if err := mapstructure.Decode(combinedParam, p.renderingConfig); err != nil {
jww.FATAL.Printf("Failed to get rendering config for %s:\n%s", p.BaseFileName(), err.Error())
}
})