diff options
Diffstat (limited to 'deps')
-rw-r--r-- | deps/deps.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/deps/deps.go b/deps/deps.go index de6d8b52a..46f4f7730 100644 --- a/deps/deps.go +++ b/deps/deps.go @@ -7,6 +7,7 @@ import ( "github.com/pkg/errors" "github.com/gohugoio/hugo/cache/filecache" + "github.com/gohugoio/hugo/common/hugo" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/helpers" @@ -62,8 +63,12 @@ type Deps struct { // The translation func to use Translate func(translationID string, args ...interface{}) string `json:"-"` + // The language in use. TODO(bep) consolidate with site Language *langs.Language + // The site building. + Site hugo.Site + // All the output formats available for the current site. OutputFormatsConfig output.Formats @@ -230,6 +235,7 @@ func New(cfg DepsCfg) (*Deps, error) { ResourceSpec: resourceSpec, Cfg: cfg.Language, Language: cfg.Language, + Site: cfg.Site, FileCaches: fileCaches, BuildStartListeners: &Listeners{}, Timeout: time.Duration(timeoutms) * time.Millisecond, @@ -245,7 +251,7 @@ func New(cfg DepsCfg) (*Deps, error) { // ForLanguage creates a copy of the Deps with the language dependent // parts switched out. -func (d Deps) ForLanguage(cfg DepsCfg) (*Deps, error) { +func (d Deps) ForLanguage(cfg DepsCfg, onCreated func(d *Deps) error) (*Deps, error) { l := cfg.Language var err error @@ -259,6 +265,8 @@ func (d Deps) ForLanguage(cfg DepsCfg) (*Deps, error) { return nil, err } + d.Site = cfg.Site + // The resource cache is global so reuse. // TODO(bep) clean up these inits. resourceCache := d.ResourceSpec.ResourceCache @@ -271,6 +279,12 @@ func (d Deps) ForLanguage(cfg DepsCfg) (*Deps, error) { d.Cfg = l d.Language = l + if onCreated != nil { + if err = onCreated(&d); err != nil { + return nil, err + } + } + if err := d.translationProvider.Clone(&d); err != nil { return nil, err } @@ -299,6 +313,9 @@ type DepsCfg struct { // The language to use. Language *langs.Language + // The Site in use + Site hugo.Site + // The configuration to use. Cfg config.Provider |