|
|
|
|
@ -1,8 +1,11 @@ |
|
|
|
|
{{ define "main" }} |
|
|
|
|
|
|
|
|
|
<!-- Have the paginator list posts, sorted by last modified date, most recent first --> |
|
|
|
|
{{ $paginator := .Paginate (.Data.Pages.ByLastmod.Reverse) 10 }} |
|
|
|
|
|
|
|
|
|
<div class="posts"> |
|
|
|
|
<!-- http://justindunham.net/blog-bells-and-whistles-in-hugo/ --> |
|
|
|
|
{{ range (.Paginator 10).Pages }} |
|
|
|
|
{{ range $paginator.Pages }} |
|
|
|
|
{{ .Render "summary"}} |
|
|
|
|
{{ end }} |
|
|
|
|
</div> |
|
|
|
|
@ -10,12 +13,11 @@ |
|
|
|
|
<p> |
|
|
|
|
<div class="pagination"> |
|
|
|
|
<!-- https://discourse.gohugo.io/t/solved-big-pagination-need-add/6576/8?u=kaushalmodi --> |
|
|
|
|
{{ $pag := $.Paginator }} |
|
|
|
|
{{ $window := $.Site.Params.paginateWindow | default 1 }} |
|
|
|
|
{{ if gt $pag.TotalPages 1 }} |
|
|
|
|
{{ $total := $pag.TotalPages }} |
|
|
|
|
{{ if gt $paginator.TotalPages 1 }} |
|
|
|
|
{{ $total := $paginator.TotalPages }} |
|
|
|
|
{{ $size := add 7 (add $window $window) }} |
|
|
|
|
{{ $cur := $pag.PageNumber }} |
|
|
|
|
{{ $cur := $paginator.PageNumber }} |
|
|
|
|
{{ if gt $total $size }} |
|
|
|
|
{{ if lt $cur (sub $size (add $window 1)) }} |
|
|
|
|
{{ $.Scratch.Set "show" (seq 1 (sub $size 2)) }} |
|
|
|
|
@ -30,13 +32,14 @@ |
|
|
|
|
{{ $.Scratch.Set "show" (seq 1 $total) }} |
|
|
|
|
{{ end }} |
|
|
|
|
|
|
|
|
|
{{ range $pag.Pagers }} |
|
|
|
|
<!-- https://gohugo.io/templates/pagination/#build-the-navigation --> |
|
|
|
|
{{ range $paginator.Pagers }} |
|
|
|
|
{{ $cur := .PageNumber }} |
|
|
|
|
{{ if in ($.Scratch.Get "show") $cur }} |
|
|
|
|
<a href="{{ .URL }}"> |
|
|
|
|
{{- if eq . $pag -}}<b>{{- end -}} |
|
|
|
|
{{- if eq . $paginator -}}<b>{{- end -}} |
|
|
|
|
{{ .PageNumber }} |
|
|
|
|
{{- if eq . $pag -}}</b>{{- end -}} |
|
|
|
|
{{- if eq . $paginator -}}</b>{{- end -}} |
|
|
|
|
</a> |
|
|
|
|
{{ else if in (slice 2 (sub $total 1)) $cur }} |
|
|
|
|
<a name="">…</a> |
|
|
|
|
|