ref: b8b8436fcca17c152e94cae2a1acad32efc3946c
parent: 42d8dfc8c88af03ea926a59bc2332acc70cca5f6
author: Bjørn Erik Pedersen <[email protected]>
date: Tue Nov 6 05:04:37 EST 2018
hugolib: Fix changing paginators in lazy render Fixes #5406
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -416,6 +416,7 @@
// a Page: If it is recently visited (the home pages will always be in this set) or changed.
// Note that a page does not have to have a content page / file.
// For regular builds, this will allways return true.
+// TODO(bep) rename/work this.
func (cfg *BuildCfg) shouldRender(p *Page) bool {
if p.forceRender {
p.forceRender = false
@@ -427,6 +428,9 @@
}
if cfg.RecentlyVisited[p.RelPermalink()] {
+ if cfg.PartialReRender {
+ _ = p.initMainOutputFormat()
+ }
return true
}
@@ -644,15 +648,13 @@
func (s *Site) preparePagesForRender(start bool) error {
for _, p := range s.Pages {
- p.setContentInit(start)
- if err := p.initMainOutputFormat(); err != nil {
+ if err := p.prepareForRender(start); err != nil {
return err
}
}
for _, p := range s.headlessPages {
- p.setContentInit(start)
- if err := p.initMainOutputFormat(); err != nil {
+ if err := p.prepareForRender(start); err != nil {
return err
}
}
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -304,7 +304,7 @@
go func() {
var err error
- err = p.prepareForRender()
+ err = p.prepareContent()
if err != nil {
c <- err
return
@@ -1142,11 +1142,17 @@
return path.Join(p.relTargetPathBase, base)
}
-func (p *Page) initMainOutputFormat() error {
- if p.mainPageOutput != nil {
- return nil
+// Prepare this page for rendering for a new site. The flag start is set
+// for the first site and output format.
+func (p *Page) prepareForRender(start bool) error {
+ p.setContentInit(start)
+ if start {
+ return p.initMainOutputFormat()
}
+ return nil
+}
+func (p *Page) initMainOutputFormat() error {
outFormat := p.outputFormats[0]
pageOutput, err := newPageOutput(p, false, false, outFormat)
@@ -1193,7 +1199,7 @@
}
-func (p *Page) prepareForRender() error {
+func (p *Page) prepareContent() error {
s := p.s
// If we got this far it means that this is either a new Page pointer