improve documentation for PageEntries functions

This commit is contained in:
nytpu
2021-03-17 09:15:26 -06:00
parent 521b162007
commit 5c735b4ce0
+6 -1
View File
@@ -148,15 +148,20 @@ type PageEntries struct {
Entries []*PageEntry
}
// Implement sort.Interface
// Implement sort.Interface for PageEntries
// Len returns the length of Entries
func (e *PageEntries) Len() int {
return len(e.Entries)
}
// Less compares the Published if Entries[i], Entries[j] and returns true if
// Entries[i] is /after/ Entries[j] (for reverse chronological sorting)
func (e *PageEntries) Less(i, j int) bool {
return e.Entries[i].Published.After(e.Entries[j].Published)
}
// Swap swaps Entries[i] and Entries[j]
func (e *PageEntries) Swap(i, j int) {
e.Entries[i], e.Entries[j] = e.Entries[j], e.Entries[i]
}