shithub: hugo

Download patch

ref: c31fa378c764cf67a9adbbad8d4291683d9d0906
parent: c20dee9d7f8b8ae46a56049895d4e7003e7b4878
author: Bjørn Erik Pedersen <[email protected]>
date: Wed Mar 23 13:11:29 EDT 2016

hugolib: Add Godoc to pageSort

--- a/hugolib/pageSort.go
+++ b/hugolib/pageSort.go
@@ -32,6 +32,7 @@
 // PageBy is a closure used in the Sort.Less method.
 type PageBy func(p1, p2 *Page) bool
 
+// Sort stable sorts the pages given the receiver's sort oder.
 func (by PageBy) Sort(pages Pages) {
 	ps := &PageSorter{
 		pages: pages,
@@ -40,6 +41,8 @@
 	sort.Stable(ps)
 }
 
+// DefaultPageSort is the default sort for pages in Hugo:
+// Order by Weight, Date, LinkTitle and then full file path.
 var DefaultPageSort = func(p1, p2 *Page) bool {
 	if p1.Weight == p2.Weight {
 		if p1.Date.Unix() == p2.Date.Unix() {
@@ -59,10 +62,13 @@
 // Less is part of sort.Interface. It is implemented by calling the "by" closure in the sorter.
 func (ps *PageSorter) Less(i, j int) bool { return ps.by(ps.pages[i], ps.pages[j]) }
 
+// Sort sorts the pages by the default sort order defined:
+// Order by Weight, Date, LinkTitle and then full file path.
 func (p Pages) Sort() {
 	PageBy(DefaultPageSort).Sort(p)
 }
 
+// Limit limits the number of pages returned to n.
 func (p Pages) Limit(n int) Pages {
 	if len(p) > n {
 		return p[0:n]