mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
Add sort pages by Title and by LinkTitle
Sorting can now be done on Title and on LinkTitle
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user