website/layouts/partials/paginator.html

67 lines
2.3 KiB
HTML
Raw Normal View History

{{ if .Site.Params.infiniteScrolling }}
2021-04-13 08:21:40 -05:00
{{- partial "js_paginator.html" . -}}
<script>
var nextPage = '/index.json';
function getNext(first=false) {
if (!nextPage) return;
fetch(nextPage).then(res => res.json())
.then(res => {
nextPage = res['next'];
if (first) {
document.getElementById('getNextBtnContainer').innerHTML += `
<div class="loadMoreButton {{ if eq .Site.Params.navtype "circles"}}buttonLike{{ end }}">
<a style="cursor: pointer" onclick="getNext();">
Load more articles
</a>
</div>
`;
return;
}
if (!nextPage) document.getElementById('getNextBtnContainer').innerHTML = '';
renderArticles(res['articles']);
});
}
getNext(true);
</script>
{{ end }}
{{ if .Site.Params.infiniteScrolling }}<noscript>{{ end }}
{{ if gt .Paginator.TotalPages 1 }}
2021-04-12 16:58:07 -05:00
{{ $navtype := .Site.Params.Navtype }}
<div id="pageNavigation" class='
2021-04-12 16:58:07 -05:00
{{ if eq $navtype "circles" }}
nav-circles
{{ end }}
'>
{{ if .Paginator.HasPrev }}
2021-04-12 16:58:07 -05:00
<a href="{{ .Paginator.Prev.URL }}" title="Previous page">
{{ if eq $navtype "circles" }}
{{ else }}
&lt;&lt;&lt;
{{ end }}
</a>
{{ end }}
{{ $currentPage := .Paginator.PageNumber }}
{{ range .Paginator.Pagers }}
{{ if ne .PageNumber $currentPage }}
<a href="{{ .URL }}">{{ .PageNumber }}</a>
{{ else }}
2021-04-12 16:58:07 -05:00
<span>
{{ if eq $navtype "circles" }}{{ .PageNumber }}
{{ else }}[{{ .PageNumber }}]{{ end }}
</span>
{{ end }}
{{ end }}
{{ if .Paginator.HasNext }}
2021-04-12 16:58:07 -05:00
<a href="{{ .Paginator.Next.URL }}" title="Next page">
{{ if eq $navtype "circles" }}
{{ else }}
&gt;&gt;&gt;
{{ end }}
</a>
{{ end }}
</div>
{{ end }}
{{ if .Site.Params.infiniteScrolling }}</noscript>{{ end }}