hugolib: Fall back to title in ByLinkTitle sort

Fixes #4953
This commit is contained in:
Bjørn Erik Pedersen
2018-11-28 12:28:24 +01:00
parent b09a40333f
commit a9a93d082d
3 changed files with 42 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ import (
"context"
"errors"
"fmt"
"math/rand"
"reflect"
"github.com/gohugoio/hugo/common/maps"
@@ -517,6 +518,14 @@ func (ps Pages) String() string {
return fmt.Sprintf("Pages(%d)", len(ps))
}
// Used in tests.
func (ps Pages) shuffle() {
for i := range ps {
j := rand.Intn(i + 1)
ps[i], ps[j] = ps[j], ps[i]
}
}
func (ps Pages) findPagePosByFilename(filename string) int {
for i, x := range ps {
if x.Filename() == filename {