2016-11-10 14:55:52 -05:00
|
|
|
// Copyright 2016-present The Hugo Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package hugolib
|
|
|
|
|
|
|
|
import (
|
2017-09-27 15:17:43 -04:00
|
|
|
"bytes"
|
2018-03-15 04:37:30 -04:00
|
|
|
"fmt"
|
2016-11-10 14:55:52 -05:00
|
|
|
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/fsnotify/fsnotify"
|
2017-06-13 12:42:45 -04:00
|
|
|
"github.com/gohugoio/hugo/helpers"
|
2016-11-10 14:55:52 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Build builds all sites. If filesystem events are provided,
|
|
|
|
// this is considered to be a potential partial rebuild.
|
|
|
|
func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
|
2018-07-11 13:23:22 -04:00
|
|
|
|
2017-09-26 14:03:04 -04:00
|
|
|
if h.Metrics != nil {
|
|
|
|
h.Metrics.Reset()
|
|
|
|
}
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
//t0 := time.Now()
|
2016-11-10 14:55:52 -05:00
|
|
|
|
|
|
|
// Need a pointer as this may be modified.
|
|
|
|
conf := &config
|
|
|
|
|
|
|
|
if conf.whatChanged == nil {
|
|
|
|
// Assume everything has changed
|
|
|
|
conf.whatChanged = &whatChanged{source: true, other: true}
|
|
|
|
}
|
|
|
|
|
2018-10-17 03:28:04 -04:00
|
|
|
if !config.PartialReRender {
|
|
|
|
for _, s := range h.Sites {
|
|
|
|
s.Deps.BuildStartListeners.Notify()
|
|
|
|
}
|
2018-07-11 13:23:22 -04:00
|
|
|
|
2018-10-17 03:28:04 -04:00
|
|
|
if len(events) > 0 {
|
|
|
|
// Rebuild
|
|
|
|
if err := h.initRebuild(conf); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := h.init(conf); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-11-10 14:55:52 -05:00
|
|
|
}
|
2018-10-17 03:28:04 -04:00
|
|
|
|
|
|
|
if err := h.process(conf, events...); err != nil {
|
2016-11-10 14:55:52 -05:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-10-17 03:28:04 -04:00
|
|
|
if err := h.assemble(conf); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-11-10 14:55:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := h.render(conf); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-27 15:17:43 -04:00
|
|
|
if h.Metrics != nil {
|
|
|
|
var b bytes.Buffer
|
|
|
|
h.Metrics.WriteMetrics(&b)
|
|
|
|
|
|
|
|
h.Log.FEEDBACK.Printf("\nTemplate Metrics:\n\n")
|
|
|
|
h.Log.FEEDBACK.Print(b.String())
|
|
|
|
h.Log.FEEDBACK.Println()
|
|
|
|
}
|
|
|
|
|
2018-10-03 08:58:09 -04:00
|
|
|
errorCount := h.Log.ErrorCounter.Count()
|
2018-03-15 04:37:30 -04:00
|
|
|
if errorCount > 0 {
|
|
|
|
return fmt.Errorf("logged %d error(s)", errorCount)
|
|
|
|
}
|
|
|
|
|
2016-11-10 14:55:52 -05:00
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build lifecycle methods below.
|
|
|
|
// The order listed matches the order of execution.
|
|
|
|
|
|
|
|
func (h *HugoSites) init(config *BuildCfg) error {
|
|
|
|
|
|
|
|
for _, s := range h.Sites {
|
|
|
|
if s.PageCollections == nil {
|
|
|
|
s.PageCollections = newPageCollections()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.ResetState {
|
|
|
|
h.reset()
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.CreateSitesFromConfig {
|
|
|
|
if err := h.createSitesFromConfig(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *HugoSites) initRebuild(config *BuildCfg) error {
|
|
|
|
if config.CreateSitesFromConfig {
|
|
|
|
return errors.New("Rebuild does not support 'CreateSitesFromConfig'.")
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.ResetState {
|
|
|
|
return errors.New("Rebuild does not support 'ResetState'.")
|
|
|
|
}
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
if !h.running {
|
2016-11-10 14:55:52 -05:00
|
|
|
return errors.New("Rebuild called when not in watch mode")
|
|
|
|
}
|
|
|
|
|
2017-02-21 07:55:08 -05:00
|
|
|
if config.whatChanged.source {
|
|
|
|
// This is for the non-renderable content pages (rarely used, I guess).
|
|
|
|
// We could maybe detect if this is really needed, but it should be
|
|
|
|
// pretty fast.
|
2017-04-30 15:52:56 -04:00
|
|
|
h.TemplateHandler().RebuildClone()
|
2017-02-21 07:55:08 -05:00
|
|
|
}
|
|
|
|
|
2016-11-10 14:55:52 -05:00
|
|
|
for _, s := range h.Sites {
|
|
|
|
s.resetBuildState()
|
|
|
|
}
|
|
|
|
|
2018-06-05 03:05:20 -04:00
|
|
|
h.resetLogs()
|
2016-11-10 14:55:52 -05:00
|
|
|
helpers.InitLoggers()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *HugoSites) process(config *BuildCfg, events ...fsnotify.Event) error {
|
|
|
|
// We should probably refactor the Site and pull up most of the logic from there to here,
|
|
|
|
// but that seems like a daunting task.
|
|
|
|
// So for now, if there are more than one site (language),
|
|
|
|
// we pre-process the first one, then configure all the sites based on that.
|
2017-02-04 22:20:06 -05:00
|
|
|
|
2016-11-10 14:55:52 -05:00
|
|
|
firstSite := h.Sites[0]
|
|
|
|
|
|
|
|
if len(events) > 0 {
|
|
|
|
// This is a rebuild
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
changed, err := firstSite.processPartial(events)
|
2016-11-10 14:55:52 -05:00
|
|
|
config.whatChanged = &changed
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return firstSite.process(*config)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *HugoSites) assemble(config *BuildCfg) error {
|
2017-02-18 04:02:12 -05:00
|
|
|
if config.whatChanged.source {
|
|
|
|
for _, s := range h.Sites {
|
|
|
|
s.createTaxonomiesEntries()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-15 04:43:49 -05:00
|
|
|
// TODO(bep) we could probably wait and do this in one go later
|
2016-11-10 14:55:52 -05:00
|
|
|
h.setupTranslations()
|
|
|
|
|
|
|
|
if len(h.Sites) > 1 {
|
|
|
|
// The first is initialized during process; initialize the rest
|
|
|
|
for _, site := range h.Sites[1:] {
|
2018-05-04 04:18:45 -04:00
|
|
|
if err := site.initializeSiteInfo(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-11-10 14:55:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.whatChanged.source {
|
|
|
|
for _, s := range h.Sites {
|
|
|
|
if err := s.buildSiteMeta(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-11 03:01:47 -05:00
|
|
|
if err := h.createMissingPages(); err != nil {
|
2016-11-10 14:55:52 -05:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, s := range h.Sites {
|
2018-01-23 08:02:54 -05:00
|
|
|
for _, pages := range []Pages{s.Pages, s.headlessPages} {
|
|
|
|
for _, p := range pages {
|
|
|
|
// May have been set in front matter
|
|
|
|
if len(p.outputFormats) == 0 {
|
|
|
|
p.outputFormats = s.outputFormats[p.Kind]
|
|
|
|
}
|
2017-03-24 04:19:51 -04:00
|
|
|
|
2018-01-23 08:02:54 -05:00
|
|
|
if p.headless {
|
|
|
|
// headless = 1 output format only
|
|
|
|
p.outputFormats = p.outputFormats[:1]
|
|
|
|
}
|
|
|
|
for _, r := range p.Resources.ByType(pageResourceType) {
|
|
|
|
r.(*Page).outputFormats = p.outputFormats
|
|
|
|
}
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
|
2018-01-23 08:02:54 -05:00
|
|
|
if err := p.initPaths(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2017-03-09 13:19:29 -05:00
|
|
|
}
|
2017-02-20 03:33:35 -05:00
|
|
|
s.assembleMenus()
|
2016-11-10 14:55:52 -05:00
|
|
|
s.refreshPageCaches()
|
2017-02-19 05:15:08 -05:00
|
|
|
s.setupSitePages()
|
2016-11-10 14:55:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := h.assignMissingTranslations(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2016-11-13 08:27:10 -05:00
|
|
|
|
2016-11-10 14:55:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *HugoSites) render(config *BuildCfg) error {
|
2018-10-17 03:28:04 -04:00
|
|
|
if !config.PartialReRender {
|
|
|
|
for _, s := range h.Sites {
|
|
|
|
s.initRenderFormats()
|
|
|
|
}
|
2018-04-23 23:57:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, s := range h.Sites {
|
2017-05-05 03:24:37 -04:00
|
|
|
for i, rf := range s.renderFormats {
|
2018-04-23 23:57:33 -04:00
|
|
|
for _, s2 := range h.Sites {
|
|
|
|
// We render site by site, but since the content is lazily rendered
|
|
|
|
// and a site can "borrow" content from other sites, every site
|
|
|
|
// needs this set.
|
|
|
|
s2.rc = &siteRenderingContext{Format: rf}
|
2018-04-19 12:06:40 -04:00
|
|
|
|
2018-04-23 23:57:33 -04:00
|
|
|
isRenderingSite := s == s2
|
|
|
|
|
2018-10-17 03:28:04 -04:00
|
|
|
if !config.PartialReRender {
|
|
|
|
if err := s2.preparePagesForRender(isRenderingSite && i == 0); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-05-08 04:10:13 -04:00
|
|
|
}
|
2018-04-23 23:57:33 -04:00
|
|
|
|
|
|
|
}
|
2017-05-05 03:24:37 -04:00
|
|
|
|
|
|
|
if !config.SkipRender {
|
2018-10-17 03:28:04 -04:00
|
|
|
if config.PartialReRender {
|
|
|
|
if err := s.renderPages(config); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := s.render(config, i); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-05 03:24:37 -04:00
|
|
|
}
|
2016-11-10 14:55:52 -05:00
|
|
|
}
|
|
|
|
}
|
2017-05-05 03:24:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if !config.SkipRender {
|
2016-11-10 14:55:52 -05:00
|
|
|
if err := h.renderCrossSitesArtifacts(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|