mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-01 13:38:50 -05:00
Revert "Improve .Content vs shortcodes"
This reverts commit e590cc26eb
.
This commit is contained in:
parent
d6982ac0ac
commit
d6a2024e6b
5 changed files with 26 additions and 77 deletions
|
@ -559,82 +559,37 @@ func (h *HugoSites) setupTranslations() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type pagesRenderPreparer struct {
|
func (s *Site) preparePagesForRender(cfg *BuildCfg) {
|
||||||
numWorkers int
|
|
||||||
s *Site
|
pageChan := make(chan *Page)
|
||||||
cfg *BuildCfg
|
wg := &sync.WaitGroup{}
|
||||||
wg *sync.WaitGroup
|
|
||||||
pages chan *Page
|
|
||||||
}
|
|
||||||
|
|
||||||
func newStartedRenderPreparator(s *Site, cfg *BuildCfg) *pagesRenderPreparer {
|
|
||||||
numWorkers := getGoMaxProcs() * 4
|
numWorkers := getGoMaxProcs() * 4
|
||||||
pp := &pagesRenderPreparer{
|
|
||||||
s: s,
|
|
||||||
cfg: cfg,
|
|
||||||
numWorkers: numWorkers,
|
|
||||||
wg: &sync.WaitGroup{},
|
|
||||||
pages: make(chan *Page),
|
|
||||||
}
|
|
||||||
|
|
||||||
pp.start()
|
for i := 0; i < numWorkers; i++ {
|
||||||
return pp
|
wg.Add(1)
|
||||||
}
|
go func(pages <-chan *Page, wg *sync.WaitGroup) {
|
||||||
|
defer wg.Done()
|
||||||
func (pp *pagesRenderPreparer) start() {
|
for p := range pages {
|
||||||
for i := 0; i < pp.numWorkers; i++ {
|
if err := p.prepareForRender(cfg); err != nil {
|
||||||
pp.wg.Add(1)
|
s.Log.ERROR.Printf("Failed to prepare page %q for render: %s", p.BaseFileName(), err)
|
||||||
go func() {
|
|
||||||
defer pp.wg.Done()
|
|
||||||
for p := range pp.pages {
|
|
||||||
if err := p.prepareForRender(pp.cfg); err != nil {
|
|
||||||
pp.s.Log.ERROR.Printf("Failed to prepare page %q for render: %s", p.BaseFileName(), err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}(pageChan, wg)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (pp *pagesRenderPreparer) add(p *Page) {
|
for _, p := range s.Pages {
|
||||||
pp.pages <- p
|
pageChan <- p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pp *pagesRenderPreparer) done() {
|
|
||||||
close(pp.pages)
|
|
||||||
pp.wg.Wait()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Site) preparePagesForRender(cfg *BuildCfg) {
|
|
||||||
|
|
||||||
// For the content from other pages in shortcodes there are some chicken and
|
|
||||||
// egg dependencies that is hard to get around. But we can improve on this
|
|
||||||
// by preparing the pages in a certain order.
|
|
||||||
// So the headless pages goes first. These are typically collection of
|
|
||||||
// pages and images etc. used by others.
|
|
||||||
batch := newStartedRenderPreparator(s, cfg)
|
|
||||||
for _, p := range s.headlessPages {
|
for _, p := range s.headlessPages {
|
||||||
batch.add(p)
|
pageChan <- p
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.done()
|
close(pageChan)
|
||||||
|
|
||||||
// Then the rest in the following order:
|
wg.Wait()
|
||||||
order := []bundleDirType{bundleLeaf, bundleNot, bundleBranch}
|
|
||||||
|
|
||||||
for _, tp := range order {
|
|
||||||
batch = newStartedRenderPreparator(s, cfg)
|
|
||||||
for _, p := range s.Pages {
|
|
||||||
// sanity check
|
|
||||||
if p.bundleType < 0 || p.bundleType > bundleBranch {
|
|
||||||
panic("unknown bundle type")
|
|
||||||
}
|
|
||||||
if p.bundleType == tp {
|
|
||||||
batch.add(p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
batch.done()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,6 @@ func (h *HugoSites) render(config *BuildCfg) error {
|
||||||
s.initRenderFormats()
|
s.initRenderFormats()
|
||||||
for i, rf := range s.renderFormats {
|
for i, rf := range s.renderFormats {
|
||||||
s.rc = &siteRenderingContext{Format: rf}
|
s.rc = &siteRenderingContext{Format: rf}
|
||||||
|
|
||||||
s.preparePagesForRender(config)
|
s.preparePagesForRender(config)
|
||||||
|
|
||||||
if !config.SkipRender {
|
if !config.SkipRender {
|
||||||
|
|
|
@ -243,8 +243,6 @@ type Page struct {
|
||||||
// 3. But you can get it via .Site.GetPage
|
// 3. But you can get it via .Site.GetPage
|
||||||
headless bool
|
headless bool
|
||||||
|
|
||||||
bundleType bundleDirType
|
|
||||||
|
|
||||||
layoutDescriptor output.LayoutDescriptor
|
layoutDescriptor output.LayoutDescriptor
|
||||||
|
|
||||||
scratch *Scratch
|
scratch *Scratch
|
||||||
|
|
|
@ -218,8 +218,6 @@ func (c *contentHandlers) parsePage(h contentHandler) contentHandler {
|
||||||
ctx.currentPage = p
|
ctx.currentPage = p
|
||||||
|
|
||||||
if ctx.bundle != nil {
|
if ctx.bundle != nil {
|
||||||
p.bundleType = ctx.bundle.tp
|
|
||||||
|
|
||||||
// Add the bundled files
|
// Add the bundled files
|
||||||
for _, fi := range ctx.bundle.resources {
|
for _, fi := range ctx.bundle.resources {
|
||||||
childCtx := ctx.childCtx(fi)
|
childCtx := ctx.childCtx(fi)
|
||||||
|
|
|
@ -1865,15 +1865,14 @@ func getGoMaxProcs() int {
|
||||||
|
|
||||||
func (s *Site) newNodePage(typ string, sections ...string) *Page {
|
func (s *Site) newNodePage(typ string, sections ...string) *Page {
|
||||||
p := &Page{
|
p := &Page{
|
||||||
bundleType: bundleBranch,
|
language: s.Language,
|
||||||
language: s.Language,
|
pageInit: &pageInit{},
|
||||||
pageInit: &pageInit{},
|
Kind: typ,
|
||||||
Kind: typ,
|
Source: Source{File: &source.FileInfo{}},
|
||||||
Source: Source{File: &source.FileInfo{}},
|
Data: make(map[string]interface{}),
|
||||||
Data: make(map[string]interface{}),
|
Site: &s.Info,
|
||||||
Site: &s.Info,
|
sections: sections,
|
||||||
sections: sections,
|
s: s}
|
||||||
s: s}
|
|
||||||
|
|
||||||
p.outputFormats = p.s.outputFormats[p.Kind]
|
p.outputFormats = p.s.outputFormats[p.Kind]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue