mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
hugolib: Prepare child page resources before the page itself
To make sure that the child resources' content is ready before any shortcode is processed in their owner. See #4632
This commit is contained in:
parent
47c05c47e0
commit
3238e14fdf
1 changed files with 10 additions and 9 deletions
|
@ -1069,6 +1069,16 @@ func (p *Page) prepareForRender(cfg *BuildCfg) error {
|
|||
// or a template or similar has changed so wee need to do a rerendering
|
||||
// of the shortcodes etc.
|
||||
|
||||
// Handle bundled pages first, so the content is available in the
|
||||
// owners' shortcodes.
|
||||
for _, r := range p.Resources.ByType(pageResourceType) {
|
||||
p.s.PathSpec.ProcessingStats.Incr(&p.s.PathSpec.ProcessingStats.Pages)
|
||||
bp := r.(*Page)
|
||||
if err := bp.prepareForRender(cfg); err != nil {
|
||||
s.Log.ERROR.Printf("Failed to prepare bundled page %q for render: %s", bp.BaseFileName(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// If in watch mode or if we have multiple output formats,
|
||||
// we need to keep the original so we can
|
||||
// potentially repeat this process on rebuild.
|
||||
|
@ -1119,15 +1129,6 @@ func (p *Page) prepareForRender(cfg *BuildCfg) error {
|
|||
//analyze for raw stats
|
||||
p.analyzePage()
|
||||
|
||||
// Handle bundled pages.
|
||||
for _, r := range p.Resources.ByType(pageResourceType) {
|
||||
p.s.PathSpec.ProcessingStats.Incr(&p.s.PathSpec.ProcessingStats.Pages)
|
||||
bp := r.(*Page)
|
||||
if err := bp.prepareForRender(cfg); err != nil {
|
||||
s.Log.ERROR.Printf("Failed to prepare bundled page %q for render: %s", bp.BaseFileName(), err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue