summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspf13 <steve.francia@gmail.com>2014-08-29 23:48:24 -0400
committerspf13 <steve.francia@gmail.com>2014-08-29 23:48:24 -0400
commit41b28462e8f427a6a2a9e4efa81a48eee7e0124b (patch)
treec982f692cca95bc42597fd4946b02af42719178e
parent70dc370c08cced68b10b46bd4a48194013536934 (diff)
Switch .Data to .Pages in the PageGroup functionality for increased consistency.
-rw-r--r--hugolib/pageGroup.go14
-rw-r--r--hugolib/site_test.go16
2 files changed, 15 insertions, 15 deletions
diff --git a/hugolib/pageGroup.go b/hugolib/pageGroup.go
index 2fd159ab8..77380a6ee 100644
--- a/hugolib/pageGroup.go
+++ b/hugolib/pageGroup.go
@@ -20,8 +20,8 @@ import (
)
type PageGroup struct {
- Key interface{}
- Data Pages
+ Key interface{}
+ Pages Pages
}
type mapKeyValues []reflect.Value
@@ -87,8 +87,8 @@ func (p Pages) GroupBy(key, order string) ([]PageGroup, error) {
}
var r []PageGroup
- for _, k := range sortKeys(tmp.MapKeys(), order) {
- r = append(r, PageGroup{Key: k.Interface(), Data: tmp.MapIndex(k).Interface().([]*Page)})
+ for _, k := range sortKeys(tmp.MapKeys(), direction) {
+ r = append(r, PageGroup{Key: k.Interface(), Pages: tmp.MapIndex(k).Interface().([]*Page)})
}
return r, nil
@@ -110,8 +110,8 @@ func (p Pages) GroupByDate(format, order string) ([]PageGroup, error) {
date := sp[0].Date.Format(format)
var r []PageGroup
- r = append(r, PageGroup{Key: date, Data: make(Pages, 0)})
- r[0].Data = append(r[0].Data, sp[0])
+ r = append(r, PageGroup{Key: date, Pages: make(Pages, 0)})
+ r[0].Pages = append(r[0].Pages, sp[0])
i := 0
for _, e := range sp[1:] {
@@ -120,7 +120,7 @@ func (p Pages) GroupByDate(format, order string) ([]PageGroup, error) {
r = append(r, PageGroup{Key: date})
i++
}
- r[i].Data = append(r[i].Data, e)
+ r[i].Pages = append(r[i].Pages, e)
}
return r, nil
}
diff --git a/hugolib/site_test.go b/hugolib/site_test.go
index 5ab09f102..aef1e0443 100644
--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -522,11 +522,11 @@ func TestGroupedPages(t *testing.T) {
if rbysection[2].Key != "sect1" {
t.Errorf("PageGroup array in unexpected order. Third group key should be '%s', got '%s'", "sect1", rbysection[2].Key)
}
- if rbysection[0].Data[0].Title != "Four" {
- t.Errorf("PageGroup has an unexpected page. First group's data should have '%s', got '%s'", "Four", rbysection[0].Data[0].Title)
+ if rbysection[0].Pages[0].Title != "Four" {
+ t.Errorf("PageGroup has an unexpected page. First group's pages should have '%s', got '%s'", "Four", rbysection[0].Pages[0].Title)
}
- if len(rbysection[2].Data) != 2 {
- t.Errorf("PageGroup has unexpected number of pages. Third group should have '%d' pages, got '%d' pages", 2, len(rbysection[2].Data))
+ if len(rbysection[2].Pages) != 2 {
+ t.Errorf("PageGroup has unexpected number of pages. Third group should have '%d' pages, got '%d' pages", 2, len(rbysection[2].Pages))
}
bydate, err := s.Pages.GroupByDate("2006-01", "asc")
@@ -542,11 +542,11 @@ func TestGroupedPages(t *testing.T) {
if bydate[2].Key != "2012-04" {
t.Errorf("PageGroup array in unexpected order. Third group key should be '%s', got '%s'", "2012-04", bydate[2].Key)
}
- if bydate[2].Data[0].Title != "Three" {
- t.Errorf("PageGroup has an unexpected page. Third group's data should have '%s', got '%s'", "Three", bydate[2].Data[0].Title)
+ if bydate[2].Pages[0].Title != "Three" {
+ t.Errorf("PageGroup has an unexpected page. Third group's pages should have '%s', got '%s'", "Three", bydate[2].Pages[0].Title)
}
- if len(bydate[0].Data) != 2 {
- t.Errorf("PageGroup has unexpected number of pages. First group should have '%d' pages, got '%d' pages", 2, len(bydate[2].Data))
+ if len(bydate[0].Pages) != 2 {
+ t.Errorf("PageGroup has unexpected number of pages. First group should have '%d' pages, got '%d' pages", 2, len(bydate[2].Pages))
}
}