diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-08-05 16:11:03 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-06 18:32:17 +0300 |
commit | 8b657a11eef3cfaa46aaa33933ab407ac855800e (patch) | |
tree | f63268db0e88f3e7412c5e4cca22991f09d4fd1b /commands | |
parent | 90de511017f9dcc65cccd7d161c70f326df3ab5b (diff) |
Get the list commands up to multi-site level
This commit also unexports some Site methods, making it clear what the external build API really is.
See #2312
Diffstat (limited to 'commands')
-rw-r--r-- | commands/list.go | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/commands/list.go b/commands/list.go index f47b4820c..423f1868f 100644 --- a/commands/list.go +++ b/commands/list.go @@ -51,13 +51,17 @@ var listDraftsCmd = &cobra.Command{ viper.Set("BuildDrafts", true) - site := &hugolib.Site{} + sites, err := hugolib.NewHugoSitesFromConfiguration() - if err := site.PreProcess(hugolib.BuildCfg{}); err != nil { + if err != nil { + return newSystemError("Error creating sites", err) + } + + if err := sites.Build(hugolib.BuildCfg{SkipRender: true}); err != nil { return newSystemError("Error Processing Source Content", err) } - for _, p := range site.AllPages { + for _, p := range sites.Pages() { if p.IsDraft() { fmt.Println(filepath.Join(p.File.Dir(), p.File.LogicalName())) } @@ -82,13 +86,17 @@ posted in the future.`, viper.Set("BuildFuture", true) - site := &hugolib.Site{} + sites, err := hugolib.NewHugoSitesFromConfiguration() + + if err != nil { + return newSystemError("Error creating sites", err) + } - if err := site.PreProcess(hugolib.BuildCfg{}); err != nil { + if err := sites.Build(hugolib.BuildCfg{SkipRender: true}); err != nil { return newSystemError("Error Processing Source Content", err) } - for _, p := range site.AllPages { + for _, p := range sites.Pages() { if p.IsFuture() { fmt.Println(filepath.Join(p.File.Dir(), p.File.LogicalName())) } @@ -113,13 +121,17 @@ expired.`, viper.Set("BuildExpired", true) - site := &hugolib.Site{} + sites, err := hugolib.NewHugoSitesFromConfiguration() + + if err != nil { + return newSystemError("Error creating sites", err) + } - if err := site.PreProcess(hugolib.BuildCfg{}); err != nil { + if err := sites.Build(hugolib.BuildCfg{SkipRender: true}); err != nil { return newSystemError("Error Processing Source Content", err) } - for _, p := range site.AllPages { + for _, p := range sites.Pages() { if p.IsExpired() { fmt.Println(filepath.Join(p.File.Dir(), p.File.LogicalName())) } |