hugelib: Add expiredCount as a Site variable
authorHanchen Wang <hanchen.wang@mail.utoronto.ca>
Wed, 11 May 2016 14:06:05 +0000 (10:06 -0400)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 14 Jun 2016 13:45:25 +0000 (15:45 +0200)
hugolib/site.go

index 679fd202a5436e34e5fdbd6bd2802885095262d6..b803864b1c80191cc4f11c8c52cce5651611a864 100644 (file)
@@ -89,6 +89,7 @@ type Site struct {
        RunMode        runmode
        draftCount     int
        futureCount    int
+       expiredCount   int
        Data           map[string]interface{}
 }
 
@@ -1006,6 +1007,10 @@ func (s *Site) addPage(page *Page) {
        if page.IsFuture() {
                s.futureCount++
        }
+
+       if page.IsExpired() {
+               s.expiredCount++
+       }
 }
 
 func (s *Site) removePageByPath(path string) {
@@ -1020,6 +1025,10 @@ func (s *Site) removePageByPath(path string) {
                        s.futureCount--
                }
 
+               if page.IsExpired() {
+                       s.expiredCount--
+               }
+
                s.Pages = append(s.Pages[:i], s.Pages[i+1:]...)
        }
 }
@@ -1034,6 +1043,10 @@ func (s *Site) removePage(page *Page) {
                        s.futureCount--
                }
 
+               if page.IsExpired() {
+                       s.expiredCount--
+               }
+
                s.Pages = append(s.Pages[:i], s.Pages[i+1:]...)
        }
 }