mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-25 15:21:27 +00:00
hugolib: Update site stats to take output formats into account
This commit is contained in:
parent
d851d6b98f
commit
0c4701f0ef
2 changed files with 18 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue