Pagination for index, list, and single page layouts

pull/3/head
Kevin C. Coram 2019-11-24 16:51:04 -05:00
parent 3365dc074a
commit f684465d00
Signed by: kevin
GPG Key ID: 0342351B3D61AD35
5 changed files with 56 additions and 4 deletions

View File

@ -9,7 +9,12 @@
<header class="list-content">
{{ .Content }}
</header>
{{ range .Pages }}
{{ range $index, $page := (.Paginate (where .Pages ".Params.hidden" "!=" "true")).Pages }}
{{ if ne $index 0 }}
{{ end }}
{{ .Render "summary" }}
{{ end }}
{{ end }}
{{ define "content-footer" }}
{{ partial "paginator.html" .Paginator }}
{{ end }}

View File

@ -10,3 +10,6 @@
{{ .Content }}
</article>
{{ end }}
{{ define "content-footer" }}
{{ partial "prev-next-page.html" . }}
{{ end }}

View File

@ -4,7 +4,12 @@
{{.Content}}
</article>
<!-- Note that .Pages is the same as .Site.RegularPages on the homepage template. -->
{{ range first 10 .Pages }}
{{ range $index, $page := (.Paginate (where (where .Site.RegularPages "Type" "in" site.Params.mainSections) ".Params.hidden" "!=" "true" )).Pages }}
{{ if ne $index 0 }}
{{ end }}
{{ .Render "summary" }}
{{ end }}
{{ end }}
{{ define "content-footer" }}
{{ partial "paginator.html" .Paginator }}
{{ end }}

View File

@ -0,0 +1,19 @@
<nav>
<ul>
<li>
{{if .HasPrev}}
<a alt="Newer articles" href="{{ .Prev.URL }}">&larr; Newer</a>
{{ else }}
&nbsp;
{{end}}
</li>
<li>Page {{ .PageNumber }} of {{ .TotalPages }}</li>
<li>
{{if .HasNext}}
<a alt="Older articles" href="{{ .Next.URL }}">Older &rarr;</a>
{{ else }}
&nbsp;
{{end}}
</li>
</ul>
</nav>

View File

@ -0,0 +1,20 @@
{{ if not .Params.Menu }}
<nav>
<ul>
<li>
{{ if .NextInSection }}
<a alt="Newer article" href="{{ .NextInSection.Permalink }}">&larr; Newer</a>
{{ else }}
&nbsp;
{{ end }} </li>
<li><a alt="Top of page" href="#">Top</a></li>
<li>
{{ if .PrevInSection }}
<a alt="Older article" href="{{ .PrevInSection.Permalink }}">Older &rarr;</a>
{{ else }}
&nbsp;
{{ end }}
</li>
</ul>
</nav>
{{ end }}