hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 0c4701f0effbf651891979b925073f6fc5d26a82
parent d851d6b98fefbe7de91c8c58b883cca4da17eea9
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Fri, 24 Mar 2017 09:19:51 +0100

hugolib: Update site stats to take output formats into account

Diffstat:
Mhugolib/hugo_sites_build.go | 8++++++++
Mhugolib/site.go | 12++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
@@ -174,11 +174,19 @@ func (h *HugoSites) assemble(config *BuildCfg) error {
 	}
 
 	for _, s := range h.Sites {
+		s.siteStats = &siteStats{}
 		for _, p := range s.Pages {
 			// May have been set in front matter
 			if len(p.outputFormats) == 0 {
 				p.outputFormats = s.outputFormats[p.Kind]
 			}
+
+			cnt := len(p.outputFormats)
+			if p.Kind == KindPage {
+				s.siteStats.pageCountRegular += cnt
+			}
+			s.siteStats.pageCount += cnt
+
 			if err := p.initTargetPathDescriptor(); err != nil {
 				return err
 			}
diff --git a/hugolib/site.go b/hugolib/site.go
@@ -115,6 +115,13 @@ type Site struct {
 
 	// Logger etc.
 	*deps.Deps `json:"-"`
+
+	siteStats *siteStats
+}
+
+type siteStats struct {
+	pageCount        int
+	pageCountRegular int
 }
 
 func (s *Site) isEnabled(kind string) bool {
@@ -1734,12 +1741,13 @@ func (s *Site) appendThemeTemplates(in []string) []string {
 // Stats prints Hugo builds stats to the console.
 // This is what you see after a successful hugo build.
 func (s *Site) Stats() {
+
 	s.Log.FEEDBACK.Printf("Built site for language %s:\n", s.Language.Lang)
 	s.Log.FEEDBACK.Println(s.draftStats())
 	s.Log.FEEDBACK.Println(s.futureStats())
 	s.Log.FEEDBACK.Println(s.expiredStats())
-	s.Log.FEEDBACK.Printf("%d regular pages created\n", len(s.RegularPages))
-	s.Log.FEEDBACK.Printf("%d other pages created\n", (len(s.Pages) - len(s.RegularPages)))
+	s.Log.FEEDBACK.Printf("%d regular pages created\n", s.siteStats.pageCountRegular)
+	s.Log.FEEDBACK.Printf("%d other pages created\n", (s.siteStats.pageCount - s.siteStats.pageCountRegular))
 	s.Log.FEEDBACK.Printf("%d non-page files copied\n", len(s.Files))
 	s.Log.FEEDBACK.Printf("%d paginator pages created\n", s.Info.paginationPageCount)