aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/hugo_sites_build.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-08-09 10:05:22 +0200
committerBjørn Erik Pedersen <[email protected]>2019-08-10 20:07:42 +0200
commitbd98182dbde893a8a809661c70633741bbf63911 (patch)
treeb6291cffa6c2e573a0976a0d70aa467c7a101012 /hugolib/hugo_sites_build.go
parente88d7989907108b656eccd92bccc076be72a5c03 (diff)
downloadhugo-bd98182dbde893a8a809661c70633741bbf63911.tar.gz
hugo-bd98182dbde893a8a809661c70633741bbf63911.zip
Implement cascading front matter
Fixes #6041
Diffstat (limited to 'hugolib/hugo_sites_build.go')
-rw-r--r--hugolib/hugo_sites_build.go48
1 files changed, 37 insertions, 11 deletions
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index 82a189a50..a70a19e7c 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -19,7 +19,10 @@ import (
"fmt"
"runtime/trace"
+ "github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/output"
+ "golang.org/x/sync/errgroup"
+ "golang.org/x/sync/semaphore"
"github.com/pkg/errors"
@@ -226,7 +229,7 @@ func (h *HugoSites) process(config *BuildCfg, init func(config *BuildCfg) error,
}
-func (h *HugoSites) assemble(config *BuildCfg) error {
+func (h *HugoSites) assemble(bcfg *BuildCfg) error {
if len(h.Sites) > 1 {
// The first is initialized during process; initialize the rest
@@ -237,23 +240,46 @@ func (h *HugoSites) assemble(config *BuildCfg) error {
}
}
- if !config.whatChanged.source {
+ if !bcfg.whatChanged.source {
return nil
}
+ numWorkers := config.GetNumWorkerMultiplier()
+ sem := semaphore.NewWeighted(int64(numWorkers))
+ g, ctx := errgroup.WithContext(context.Background())
+
for _, s := range h.Sites {
- if err := s.assemblePagesMap(s); err != nil {
- return err
- }
+ s := s
+ g.Go(func() error {
+ err := sem.Acquire(ctx, 1)
+ if err != nil {
+ return err
+ }
+ defer sem.Release(1)
- if err := s.pagesMap.assembleTaxonomies(s); err != nil {
- return err
- }
+ if err := s.assemblePagesMap(s); err != nil {
+ return err
+ }
- if err := s.createWorkAllPages(); err != nil {
- return err
- }
+ if err := s.pagesMap.assemblePageMeta(); err != nil {
+ return err
+ }
+
+ if err := s.pagesMap.assembleTaxonomies(s); err != nil {
+ return err
+ }
+
+ if err := s.createWorkAllPages(); err != nil {
+ return err
+ }
+
+ return nil
+ })
+ }
+
+ if err := g.Wait(); err != nil {
+ return err
}
if err := h.createPageCollections(); err != nil {