hugo-theme-moments/layouts/index.html
2022-10-20 19:45:38 +08:00

40 lines
1.3 KiB
HTML

{{ define "main" }}
<div class="container">
{{ $paginator := .Paginate ((where .Site.RegularPages "Section" "moments").ByParam "top") }}
{{ range $paginator.Pages }}
{{ partial "row.html" . }}
{{ end }}
</div>
{{ if .Site.Params.infiniteScroll }}
{{ partial "loading.html" . }}
{{ end }}
{{ end }}
{{ define "pagination" }}
{{ $paginator := .Paginate ((where .Site.RegularPages "Section" "moments").ByParam "top") }}
{{ if $paginator.HasPrev }}
<a class="page-link" href="{{$.Site.BaseURL}}/{{sub $paginator.PageNumber 1 }}">
<div class="page-item">< Prev</div>
</a>
{{ else }}
<div class="page-item disabled">< Prev</div>
{{ end }}
{{ $current_num := $paginator.PageNumber }}
{{ range (seq 1 $paginator.TotalPages) }}
{{ if (eq $current_num .)}}
<div class="page-item active">{{.}}</div>
{{ else }}
<a class="page-link" href="{{$.Site.BaseURL}}/{{.}}"><div class="page-item">{{.}}</div></a>
{{ end }}
{{end}}
{{ if $paginator.HasNext }}
<a class="page-link" href="{{$.Site.BaseURL}}/{{ add $paginator.PageNumber 1 }}">
<div class="page-item">Next ></div>
</a>
{{ else }}
<div class="page-item disabled">Next ></div>
{{ end }}
{{ end }}