mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
Move blackfriday site-wide config loading to NewBlackFriday()
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
fde47c5eb9
commit
5838420aa1
@@ -246,26 +246,10 @@ func (p *Page) renderContent(content []byte) []byte {
|
||||
func (p *Page) getRenderingConfig() *helpers.Blackfriday {
|
||||
|
||||
p.renderingConfigInit.Do(func() {
|
||||
pageParam := p.GetParam("blackfriday")
|
||||
siteParam := viper.GetStringMap("blackfriday")
|
||||
pageParam := cast.ToStringMap(p.GetParam("blackfriday"))
|
||||
|
||||
combinedParam := siteParam
|
||||
|
||||
if pageParam != nil {
|
||||
combinedParam = make(map[string]interface{})
|
||||
|
||||
for k, v := range siteParam {
|
||||
combinedParam[k] = v
|
||||
}
|
||||
|
||||
pageConfig := cast.ToStringMap(pageParam)
|
||||
|
||||
for key, value := range pageConfig {
|
||||
combinedParam[key] = value
|
||||
}
|
||||
}
|
||||
p.renderingConfig = helpers.NewBlackfriday()
|
||||
if err := mapstructure.Decode(combinedParam, p.renderingConfig); err != nil {
|
||||
if err := mapstructure.Decode(pageParam, p.renderingConfig); err != nil {
|
||||
jww.FATAL.Printf("Failed to get rendering config for %s:\n%s", p.BaseFileName(), err.Error())
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user