commit eec0e512f9ff7820cffefbf5c80b90c10c28b018
parent 3dfb4751366aadfec9056ca3bde4215067ee4a26
Author: Ruben <ruben.nellen@gmail.com>
Date: Wed, 5 Mar 2014 07:29:57 +0100
Add sort pages by Title and by LinkTitle
Sorting can now be done on Title and on LinkTitle
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/hugolib/pageSort.go b/hugolib/pageSort.go
@@ -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()