diff options
author | Alexandre Vicenzi <vicenzi.alexandre@gmail.com> | 2020-05-25 23:34:28 +0300 |
---|---|---|
committer | Alexandre Vicenzi <vicenzi.alexandre@gmail.com> | 2020-05-25 23:55:26 +0300 |
commit | 967d8ae4e6fcd229bc3c76e012118b48a978f0dd (patch) | |
tree | 3676d9eb441b0fc049dfe9c246b85e95a4ff9afa /layouts | |
parent | 83b9fd18ee4307952caf7c3a5f0cc3ec51c27852 (diff) |
Add pagination
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/index.html | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/layouts/index.html b/layouts/index.html index 28e95ae..3de3e62 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -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 }} |