Added pagination

This commit is contained in:
Xavi 2023-03-13 16:28:48 -07:00
parent 1f249d15c3
commit c509d28afc
4 changed files with 63 additions and 1 deletions

View File

@ -1,5 +1,6 @@
baseURL = 'https://xavishobbies.org/'
languageCode = 'en-us'
title = 'Xavis Hobbies'
paginate = 5
theme='xavis'

View File

@ -9,9 +9,10 @@
{{ end }}
{{ $paginator := .Paginate (where .Pages "Params.categories" "intersect" (slice "Top_of_the_Stack")) }}
<h3 style="margin-bottom: 0px"> Tots Posts </h3>
{{ range where .Pages "Params.categories" "intersect" (slice "Top_of_the_Stack") }}
{{ range $paginator.Pages }}
<div class="tots_post">
<h3 class="entry_heading">{{ .Title }}</h3>
@ -21,4 +22,5 @@
</div>
{{ end }}
{{ partial "pagination.html" . }}
{{ end }}

View File

@ -0,0 +1,40 @@
{{ $pag := $.Paginator }}
{{ if gt $pag.TotalPages 1 }}
<ul class="pagination">
{{ with $pag.First }}
<li class="page-item-nav">
<a href="{{ .URL }}" class="page-link" aria-label="First"><span aria-hidden="true">&laquo;&laquo;</span></a>
</li>
{{ end }}
<li class="page-item-nav{{ if not $pag.HasPrev }} disabled{{ end }}">
<a {{ if $pag.HasPrev }}href="{{ $pag.Prev.URL }}"{{ end }} class="page-link" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
</li>
{{ $ellipsed := false }}
{{ $shouldEllipse := false }}
{{ range $pag.Pagers }}
{{ $right := sub .TotalPages .PageNumber }}
{{ $showNumber := or (le .PageNumber 3) (eq $right 0) }}
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
{{ if $showNumber }}
{{ $ellipsed = false }}
{{ $shouldEllipse = false }}
{{ else }}
{{ $shouldEllipse = not $ellipsed }}
{{ $ellipsed = true }}
{{ end }}
{{ if $showNumber }}
<li class="page-item{{ if eq . $pag }} active{{ end }}"><a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a></li>
{{ else if $shouldEllipse }}
<li class="page-item disabled"><span aria-hidden="true">&nbsp;&hellip;&nbsp;</span></li>
{{ end }}
{{ end }}
<li class="page-item-nav{{ if not $pag.HasNext }} disabled{{ end }}">
<a {{ if $pag.HasNext }}href="{{ $pag.Next.URL }}"{{ end }} class="page-link" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
</li>
{{ with $pag.Last }}
<li class="page-item-nav">
<a href="{{ .URL }}" class="page-link" aria-label="Last"><span aria-hidden="true">&raquo;&raquo;</span></a>
</li>
{{ end }}
</ul>
{{ end }}

View File

@ -162,6 +162,25 @@ img.resize{
margin-bottom: 0px;
}
.pagination{
font-size:0px;
text-align:center;
padding:15px;
}
.page-item{
font-size:15px;
display:inline-block;
border:1px solid #470161;
padding:3px;
}
.page-item-nav{
font-size:15px;
display:inline-block;
padding:4px;
}
#ascii_site_heading{
color: #ff00e5;
}