Add sort pages by Title and by LinkTitle

Sorting can now be done on Title and on LinkTitle
This commit is contained in:
Ruben authored and spf13 committed 2014-03-13 11:39:13 +01:00
1 parent 3dfb475136
commit eec0e512f9
1 file changed
+18
+18
View File
@@ -69,6 +69,24 @@ func (p Pages) ByWeight() Pages {
return p
}
func (p Pages) ByTitle() Pages {
title := func(p1, p2 *Page) bool {
return p1.Title < p2.Title
}
PageBy(title).Sort(p)
return p
}
func (p Pages) ByLinkTitle() Pages {
linkTitle := func(p1, p2 *Page) bool {
return p1.linkTitle < p2.linkTitle
}
PageBy(linkTitle).Sort(p)
return p
}
func (p Pages) ByDate() Pages {
date := func(p1, p2 *Page) bool {
return p1.Date.Unix() < p2.Date.Unix()