Fixed pager

This commit is contained in:
James Mills
2021-02-03 01:56:56 +10:00
parent 382fd677c3
commit 6dc7510e8f
6 changed files with 37 additions and 20 deletions

View File

@@ -1,24 +1,24 @@
{{ define "pager" }}
{{ if .HasPages }}
{{ if $.Pager.HasPages }}
<nav class="pagination-nav">
<ul>
<li>
{{ if .HasPrev }}
<a href="?p={{ .PrevPage }}">Prev</a>
{{ if $.Pager.HasPrev }}
<a href="?q={{ $.SearchQuery }}&p={{ $.Pager.PrevPage }}">Prev</a>
{{ else }}
<a href="#" data-tooltip="No previous page">Prev</a>
<a href="#" data-tooltip="No more results">Prev</a>
{{ end }}
</li>
</ul>
<ul>
<li><small>Page {{ .Page }}/{{ .PageNums }} of {{ .Nums }} Results</small></li>
<li><small>Viewing page {{ $.Pager.Page }}/{{ $.Pager.PageNums }} of {{ $.Pager.Nums }} results (Search took: {{ $.SearchTook }})</small></li>
</ul>
<ul>
<li>
{{ if .HasNext }}
<a href="?p={{ .NextPage }}">Next</a>
{{ if $.Pager.HasNext }}
<a href="?q={{ $.SearchQuery }}&p={{ $.Pager.NextPage }}">Next</a>
{{ else }}
<a href="#" data-tooltip="No next page">Next</a>
<a href="#" data-tooltip="No more results">Next</a>
{{ end }}
</li>
</ul>

View File

@@ -8,8 +8,8 @@
</button>
</form>
</div>
{{ template "pager" (dict "Pager" $.Pager "SearchQuery" $.SearchQuery "SearchTook" $.SearchTook) }}
<div class="container">
<p>Found {{ $.Matches }} matches in {{ $.Duration }}</p>
{{ with $.Results }}
{{ range . }}
<article>
@@ -22,4 +22,5 @@
{{ end }}
{{ end }}
</div>
{{ template "pager" (dict "Pager" $.Pager "SearchQuery" $.SearchQuery) }}
{{end}}