mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Group vars in paginator
It's easier to read.
This commit is contained in:
parent
b47652fb29
commit
48870fef2e
1 changed files with 15 additions and 7 deletions
|
@ -49,8 +49,10 @@ func (psg PagesGroup) Len() int {
|
|||
|
||||
type pagers []*Pager
|
||||
|
||||
var paginatorEmptyPages Pages
|
||||
var paginatorEmptyPageGroups PagesGroup
|
||||
var (
|
||||
paginatorEmptyPages Pages
|
||||
paginatorEmptyPageGroups PagesGroup
|
||||
)
|
||||
|
||||
type paginator struct {
|
||||
paginatedElements []paginatedElement
|
||||
|
@ -208,14 +210,16 @@ func splitPages(pages Pages, size int) []paginatedElement {
|
|||
}
|
||||
|
||||
func splitPageGroups(pageGroups PagesGroup, size int) []paginatedElement {
|
||||
var split []paginatedElement
|
||||
|
||||
type keyPage struct {
|
||||
key interface{}
|
||||
page *Page
|
||||
}
|
||||
|
||||
var flattened []keyPage
|
||||
var (
|
||||
split []paginatedElement
|
||||
flattened []keyPage
|
||||
)
|
||||
|
||||
for _, g := range pageGroups {
|
||||
for _, p := range g.Pages {
|
||||
|
@ -227,9 +231,13 @@ func splitPageGroups(pageGroups PagesGroup, size int) []paginatedElement {
|
|||
|
||||
for low, j := 0, numPages; low < j; low += size {
|
||||
high := int(math.Min(float64(low+size), float64(numPages)))
|
||||
var pg PagesGroup
|
||||
var key interface{} = nil
|
||||
var groupIndex = -1
|
||||
|
||||
var (
|
||||
pg PagesGroup
|
||||
key interface{} = nil
|
||||
groupIndex = -1
|
||||
)
|
||||
|
||||
for k := low; k < high; k++ {
|
||||
kp := flattened[k]
|
||||
if key == nil || key != kp.key {
|
||||
|
|
Loading…
Reference in a new issue