2017-07-03 15:48:41 +02:00
|
|
|
package collections
|
|
|
|
|
2017-07-03 19:03:45 +02:00
|
|
|
import (
|
|
|
|
"github.com/osteele/gojekyll/pages"
|
|
|
|
)
|
2017-07-03 15:48:41 +02:00
|
|
|
|
|
|
|
type pagesByDate struct{ pages []pages.Page }
|
|
|
|
|
|
|
|
// Len is part of sort.Interface.
|
|
|
|
func (p pagesByDate) Len() int {
|
|
|
|
return len(p.pages)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Less is part of sort.Interface.
|
|
|
|
func (p pagesByDate) Less(i, j int) bool {
|
|
|
|
a, b := p.pages[i].PostDate(), p.pages[j].PostDate()
|
2017-07-03 19:03:45 +02:00
|
|
|
return a.After(b)
|
2017-07-03 15:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Swap is part of sort.Interface.
|
|
|
|
func (p pagesByDate) Swap(i, j int) {
|
|
|
|
pages := p.pages
|
|
|
|
pages[i], pages[j] = pages[j], pages[i]
|
|
|
|
}
|