diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/hugo.go | 6 | ||||
-rw-r--r-- | commands/list.go | 6 | ||||
-rw-r--r-- | commands/multilingual.go | 29 |
3 files changed, 21 insertions, 20 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index 959006557..9ad46b3bf 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -49,7 +49,7 @@ import ( // Hugo represents the Hugo sites to build. This variable is exported as it // is used by at least one external library (the Hugo caddy plugin). We should // provide a cleaner external API, but until then, this is it. -var Hugo hugolib.HugoSites +var Hugo *hugolib.HugoSites // Reset resets Hugo ready for a new full build. This is mainly only useful // for benchmark testing etc. via the CLI commands. @@ -715,11 +715,11 @@ func getDirList() []string { func buildSites(watching ...bool) (err error) { fmt.Println("Started building sites ...") w := len(watching) > 0 && watching[0] - return Hugo.Build(w, true) + return Hugo.Build(hugolib.BuildCfg{Watching: w, PrintStats: true}) } func rebuildSites(events []fsnotify.Event) error { - return Hugo.Rebuild(events, true) + return Hugo.Rebuild(hugolib.BuildCfg{PrintStats: true}, events...) } // NewWatcher creates a new watcher to watch filesystem events. diff --git a/commands/list.go b/commands/list.go index bc5bb557a..f47b4820c 100644 --- a/commands/list.go +++ b/commands/list.go @@ -53,7 +53,7 @@ var listDraftsCmd = &cobra.Command{ site := &hugolib.Site{} - if err := site.Process(); err != nil { + if err := site.PreProcess(hugolib.BuildCfg{}); err != nil { return newSystemError("Error Processing Source Content", err) } @@ -84,7 +84,7 @@ posted in the future.`, site := &hugolib.Site{} - if err := site.Process(); err != nil { + if err := site.PreProcess(hugolib.BuildCfg{}); err != nil { return newSystemError("Error Processing Source Content", err) } @@ -115,7 +115,7 @@ expired.`, site := &hugolib.Site{} - if err := site.Process(); err != nil { + if err := site.PreProcess(hugolib.BuildCfg{}); err != nil { return newSystemError("Error Processing Source Content", err) } diff --git a/commands/multilingual.go b/commands/multilingual.go index 7c43d15bc..4d0f6e107 100644 --- a/commands/multilingual.go +++ b/commands/multilingual.go @@ -11,30 +11,31 @@ import ( "github.com/spf13/viper" ) -func readMultilingualConfiguration() (hugolib.HugoSites, error) { - h := make(hugolib.HugoSites, 0) +func readMultilingualConfiguration() (*hugolib.HugoSites, error) { + sites := make([]*hugolib.Site, 0) multilingual := viper.GetStringMap("Multilingual") if len(multilingual) == 0 { // TODO(bep) multilingo langConfigsList = append(langConfigsList, hugolib.NewLanguage("en")) - h = append(h, hugolib.NewSite(hugolib.NewLanguage("en"))) - return h, nil + sites = append(sites, hugolib.NewSite(hugolib.NewLanguage("en"))) } - var err error + if len(multilingual) > 0 { + var err error - langConfigsList, err := toSortedLanguages(multilingual) + languages, err := toSortedLanguages(multilingual) - if err != nil { - return nil, fmt.Errorf("Failed to parse multilingual config: %s", err) - } + if err != nil { + return nil, fmt.Errorf("Failed to parse multilingual config: %s", err) + } + + for _, lang := range languages { + sites = append(sites, hugolib.NewSite(lang)) + } - for _, lang := range langConfigsList { - s := hugolib.NewSite(lang) - s.SetMultilingualConfig(lang, langConfigsList) - h = append(h, s) } - return h, nil + return hugolib.NewHugoSites(sites...) + } func toSortedLanguages(l map[string]interface{}) (hugolib.Languages, error) { |