mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-27 03:23:55 +00:00
support for futre/draft summary info output
This commit is contained in:
parent
946ad9c2c3
commit
c750a95e22
2 changed files with 62 additions and 1 deletions
|
@ -304,6 +304,17 @@ func (page *Page) ShouldBuild() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (page *Page) IsDraft() bool {
|
||||
return page.Draft
|
||||
}
|
||||
|
||||
func (page *Page) IsFuture() bool {
|
||||
if page.PublishDate.Before(time.Now()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *Page) Permalink() (string, error) {
|
||||
link, err := p.permalink()
|
||||
if err != nil {
|
||||
|
|
|
@ -70,6 +70,8 @@ type Site struct {
|
|||
Completed chan bool
|
||||
RunMode runmode
|
||||
params map[string]interface{}
|
||||
draftCount int
|
||||
futureCount int
|
||||
}
|
||||
|
||||
type SiteInfo struct {
|
||||
|
@ -348,6 +350,14 @@ func (s *Site) CreatePages() (err error) {
|
|||
s.Pages = append(s.Pages, page)
|
||||
}
|
||||
|
||||
if page.IsDraft() {
|
||||
s.draftCount += 1
|
||||
}
|
||||
|
||||
if page.IsFuture() {
|
||||
s.futureCount += 1
|
||||
}
|
||||
|
||||
return
|
||||
}(fi)
|
||||
}
|
||||
|
@ -806,7 +816,9 @@ func (s *Site) RenderSitemap() error {
|
|||
}
|
||||
|
||||
func (s *Site) Stats() {
|
||||
jww.FEEDBACK.Printf("%d pages created \n", len(s.Pages))
|
||||
jww.FEEDBACK.Println(s.draftStats())
|
||||
jww.FEEDBACK.Println(s.futureStats())
|
||||
jww.FEEDBACK.Printf("%d pages created \n", len(s.Pages))
|
||||
|
||||
taxonomies := viper.GetStringMapString("Taxonomies")
|
||||
|
||||
|
@ -951,3 +963,41 @@ func (s *Site) WriteAlias(path string, permalink template.HTML) (err error) {
|
|||
|
||||
return s.Alias.Publish(path, permalink)
|
||||
}
|
||||
|
||||
func (s *Site) draftStats() string {
|
||||
var msg string
|
||||
|
||||
switch s.draftCount {
|
||||
case 0:
|
||||
return "0 draft content "
|
||||
case 1:
|
||||
msg = "1 draft rendered "
|
||||
default:
|
||||
msg = fmt.Sprintf("%d drafts rendered", s.draftCount)
|
||||
}
|
||||
|
||||
if viper.GetBool("BuildDrafts") {
|
||||
return fmt.Sprintf("%d of ", s.draftCount) + msg
|
||||
}
|
||||
|
||||
return "0 of " + msg
|
||||
}
|
||||
|
||||
func (s *Site) futureStats() string {
|
||||
var msg string
|
||||
|
||||
switch s.futureCount {
|
||||
case 0:
|
||||
return "0 future content "
|
||||
case 1:
|
||||
msg = "1 future rendered "
|
||||
default:
|
||||
msg = fmt.Sprintf("%d future rendered", s.draftCount)
|
||||
}
|
||||
|
||||
if viper.GetBool("BuildFuture") {
|
||||
return fmt.Sprintf("%d of ", s.futureCount) + msg
|
||||
}
|
||||
|
||||
return "0 of " + msg
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue