mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 19:32:10 -05:00
Add sort pages by Title and by LinkTitle
Sorting can now be done on Title and on LinkTitle
This commit is contained in:
parent
3dfb475136
commit
eec0e512f9
1 changed files with 18 additions and 0 deletions
|
@ -69,6 +69,24 @@ func (p Pages) ByWeight() Pages {
|
||||||
return p
|
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 {
|
func (p Pages) ByDate() Pages {
|
||||||
date := func(p1, p2 *Page) bool {
|
date := func(p1, p2 *Page) bool {
|
||||||
return p1.Date.Unix() < p2.Date.Unix()
|
return p1.Date.Unix() < p2.Date.Unix()
|
||||||
|
|
Loading…
Reference in a new issue