diff --git a/filters/filters.go b/filters/filters.go index 3fa1999..0a067b8 100644 --- a/filters/filters.go +++ b/filters/filters.go @@ -261,4 +261,3 @@ func whereFilter(array []map[string]interface{}, key string, value interface{}) } return out } - diff --git a/pages/page.go b/pages/page.go index 67b0fe1..90e71c5 100644 --- a/pages/page.go +++ b/pages/page.go @@ -106,16 +106,17 @@ func (p *page) Write(w io.Writer, rc RenderingContext) error { // Content computes the page content. func (p *page) Content(rc RenderingContext) ([]byte, error) { - if p.content == nil { - rp := rc.RenderingPipeline() - buf := new(bytes.Buffer) - b, err := rp.Render(buf, p.raw, p.filename, p.firstLine, p.TemplateContext(rc)) - if err != nil { - return nil, err - } - p.content = &b + if p.content != nil { + return *p.content, nil } - return *p.content, nil + rp := rc.RenderingPipeline() + buf := new(bytes.Buffer) + b, err := rp.Render(buf, p.raw, p.filename, p.firstLine, p.TemplateContext(rc)) + if err != nil { + return nil, err + } + p.content = &b + return b, nil } // retains content diff --git a/plugins/redirect_from.go b/plugins/redirect_from.go index 0d16ed7..509b48d 100644 --- a/plugins/redirect_from.go +++ b/plugins/redirect_from.go @@ -23,7 +23,6 @@ func init() { redirectTemplate = tmpl } - func (p jekyllRedirectFromPlugin) PostRead(site Site) error { redirections := []pages.Document{} for _, p := range site.Pages() { diff --git a/site/drop.go b/site/drop.go index d0b5734..45b15e5 100644 --- a/site/drop.go +++ b/site/drop.go @@ -10,14 +10,13 @@ import ( // ToLiquid returns the site variable for template evaluation. func (s *Site) ToLiquid() interface{} { - // double-checked lock is okay here, since it's okay if this is - // computed and set twice + if len(s.drop) > 0 { + return s.drop + } + s.Lock() + defer s.Unlock() if len(s.drop) == 0 { - s.Lock() - defer s.Unlock() - if len(s.drop) == 0 { - s.initializeDrop() - } + s.initializeDrop() } return s.drop }