mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
hugolib: Fix possible .Content cut
There have been one report of a site with truncated `.Content` after the Hugo `0.40.1` release. This commit fixes this so that race should not be possible anymore. It also adds a stress test with focus on content rendering and multiple output formats. Fixes #4706
This commit is contained in:
@@ -73,7 +73,7 @@ func headlessPagesPublisher(s *Site, wg *sync.WaitGroup) {
|
||||
// Avoid double work.
|
||||
continue
|
||||
}
|
||||
pageOutput, err := newPageOutput(page, false, outFormat)
|
||||
pageOutput, err := newPageOutput(page, false, false, outFormat)
|
||||
if err == nil {
|
||||
page.mainPageOutput = pageOutput
|
||||
err = pageOutput.renderResources()
|
||||
@@ -92,23 +92,20 @@ func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.Wa
|
||||
|
||||
for i, outFormat := range page.outputFormats {
|
||||
|
||||
if outFormat != page.s.rc.Format {
|
||||
// Will be rendered ... later.
|
||||
continue
|
||||
}
|
||||
|
||||
var (
|
||||
pageOutput *PageOutput
|
||||
err error
|
||||
)
|
||||
|
||||
if i == 0 {
|
||||
pageOutput, err = newPageOutput(page, false, outFormat)
|
||||
page.mainPageOutput = pageOutput
|
||||
}
|
||||
|
||||
if outFormat != page.s.rc.Format {
|
||||
// Will be rendered ... later.
|
||||
continue
|
||||
}
|
||||
|
||||
if pageOutput == nil {
|
||||
pageOutput, err = page.mainPageOutput.copyWithFormat(outFormat)
|
||||
pageOutput = page.mainPageOutput
|
||||
} else {
|
||||
pageOutput, err = page.mainPageOutput.copyWithFormat(outFormat, true)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -116,6 +113,10 @@ func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.Wa
|
||||
continue
|
||||
}
|
||||
|
||||
if pageOutput == nil {
|
||||
panic("no pageOutput")
|
||||
}
|
||||
|
||||
// We only need to re-publish the resources if the output format is different
|
||||
// from all of the previous (e.g. the "amp" use case).
|
||||
shouldRender := i == 0
|
||||
@@ -291,7 +292,7 @@ func (s *Site) render404() error {
|
||||
htmlOut := output.HTMLFormat
|
||||
htmlOut.BaseName = "404"
|
||||
|
||||
pageOutput, err := newPageOutput(p, false, htmlOut)
|
||||
pageOutput, err := newPageOutput(p, false, false, htmlOut)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -373,7 +374,7 @@ func (s *Site) renderRobotsTXT() error {
|
||||
|
||||
rLayouts := []string{"robots.txt", "_default/robots.txt", "_internal/_default/robots.txt"}
|
||||
|
||||
pageOutput, err := newPageOutput(p, false, output.RobotsTxtFormat)
|
||||
pageOutput, err := newPageOutput(p, false, false, output.RobotsTxtFormat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user