projects
/
brevno-suite
/
hugo
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3dfb475
)
Add sort pages by Title and by LinkTitle
author
Ruben
<ruben.nellen@gmail.com>
Wed, 5 Mar 2014 06:29:57 +0000
(07:29 +0100)
committer
spf13
<steve.francia@gmail.com>
Thu, 13 Mar 2014 10:39:13 +0000
(11:39 +0100)
Sorting can now be done on Title and on LinkTitle
hugolib/pageSort.go
patch
|
blob
|
history
diff --git
a/hugolib/pageSort.go
b/hugolib/pageSort.go
index a50c464c8e12e2ecfd00ff4447d5edc443f9be41..63e230ac0fd38797710920f61bc56e613cb69532 100644
(file)
--- 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()