Add pagination
This commit is contained in:
parent
83b9fd18ee
commit
967d8ae4e6
2 changed files with 97 additions and 23 deletions
|
@ -1,29 +1,36 @@
|
|||
{{ define "main" -}}
|
||||
<div class="posts">
|
||||
{{ range .Site.RegularPages -}}
|
||||
{{ if and (or (eq .Type "post") (eq .Type "article")) (or (not (isset .Params "Hidden")) (eq .Params.Hidden false)) -}}
|
||||
<article class="post">
|
||||
<h1 class="post-title">
|
||||
<a href="{{ .Permalink }}">{{ .Title }}</a>
|
||||
</h1>
|
||||
<div class="posts">
|
||||
{{- $regularPages := where .Site.RegularPages "Type" "in" .Site.Params.MainSections -}}
|
||||
{{- $pagesNotHidden := where $regularPages ".Params.hidden" "==" false -}}
|
||||
{{- $pagesHiddenUnset := where $regularPages ".Params.hidden" "==" nil -}}
|
||||
|
||||
<div class="post-date">
|
||||
<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z0700" }}">{{ .Date.Format "Jan 2, 2006" }}</time> · {{ .ReadingTime }} min read
|
||||
</div>
|
||||
{{- $pages := $pagesNotHidden | union $pagesHiddenUnset -}}
|
||||
{{- $paginator := .Paginate $pages -}}
|
||||
|
||||
{{ if .Description }}
|
||||
{{ .Description }}
|
||||
{{ else }}
|
||||
{{ .Summary }}
|
||||
{{ end }}
|
||||
{{ range $paginator.Pages }}
|
||||
<article class="post">
|
||||
<h1 class="post-title">
|
||||
<a href="{{ .Permalink }}">{{ .Title }}</a>
|
||||
</h1>
|
||||
|
||||
{{ if .Truncated }}
|
||||
<div class="read-more-link">
|
||||
<a href="{{ .RelPermalink }}">Read More</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</article>
|
||||
<div class="post-date">
|
||||
<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z0700" }}">{{ .Date.Format "Jan 2, 2006" }}</time> · {{ .ReadingTime }} min read
|
||||
</div>
|
||||
|
||||
{{ if .Description }}
|
||||
{{ .Description }}
|
||||
{{ else }}
|
||||
{{ .Summary }}
|
||||
{{ end }}
|
||||
|
||||
{{ if .Truncated }}
|
||||
<div class="read-more-link">
|
||||
<a href="{{ .RelPermalink }}">Read More</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</article>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ template "_internal/pagination.html" . }}
|
||||
{{- end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue