website/layouts/partials/pagination.html
ROOMrepair 85ebc72aee fix: try to fix docs pagination bugs
Signed-off-by: ROOMrepair <twekjz@gmail.com>
2024-10-31 18:18:41 +08:00

33 lines
887 B
HTML

<div class="page-div common-flex-layout">
<!-- if not each page in a section is pure page we can't simply use prev/nextInsection -->
<!-- or is there a better way -->
{{ $current := .}}
{{ $p := .Parent.Pages.ByWeight }}
{{ $length := len $p }}
<!-- find current page's section position -->
{{ $curIndex := 0 }}
{{ range $i, $p_sec := $p}}
{{ if eq $p_sec $current}}
{{ $curIndex = $i }}
{{ end }}
{{ end }}
<!-- prev -->
{{ if gt $curIndex 0}}
{{ $prevPage := index $p (sub $curIndex 1) }}
{{ partial "findLastInPreSection" $prevPage}}
{{ else }}
{{ partial "page_navigation" (dict "context" . "prev" true)}}
{{ end }}
<!-- next -->
{{ if lt $curIndex (sub $length 1) }}
{{ $nextPage := index $p (add $curIndex 1)}}
{{ partial "findFirstInNextSection" $nextPage}}
{{ else }}
{{ partial "page_navigation" (dict "context" . "prev" false)}}
{{ end }}
</div>