"path"
"path/filepath"
"strings"
+ "sync"
"time"
)
Tmpl tpl.Template
Markup string
- extension string
- contentType string
- renderable bool
- layout string
- linkTitle string
- frontmatter []byte
- rawContent []byte
- contentShortCodes map[string]string
- plain string // TODO should be []byte
+ extension string
+ contentType string
+ renderable bool
+ layout string
+ linkTitle string
+ frontmatter []byte
+ rawContent []byte
+ contentShortCodes map[string]string
+ plain string // TODO should be []byte
+ renderingConfigFlags map[string]bool
+ renderingConfigFlagsInit sync.Once
PageMeta
Source
Position
}
func (p *Page) getRenderingConfigFlags() map[string]bool {
- flags := make(map[string]bool)
- pageParam := p.GetParam("blackfriday")
- siteParam := viper.GetStringMap("blackfriday")
+ p.renderingConfigFlagsInit.Do(func() {
+ p.renderingConfigFlags = make(map[string]bool)
- flags = cast.ToStringMapBool(siteParam)
+ pageParam := p.GetParam("blackfriday")
+ siteParam := viper.GetStringMap("blackfriday")
- if pageParam != nil {
- pageFlags := cast.ToStringMapBool(pageParam)
- for key, value := range pageFlags {
- flags[key] = value
+ p.renderingConfigFlags = cast.ToStringMapBool(siteParam)
+
+ if pageParam != nil {
+ pageFlags := cast.ToStringMapBool(pageParam)
+ for key, value := range pageFlags {
+ p.renderingConfigFlags[key] = value
+ }
}
- }
+ })
- return flags
+ return p.renderingConfigFlags
}
func (p *Page) isRenderingFlagEnabled(flag string) bool {