diff options
author | Fabien CASTERS <fabien@vaga.io> | 2019-03-04 22:59:18 +0300 |
---|---|---|
committer | Fabien <vaga@users.noreply.github.com> | 2019-03-04 23:21:23 +0300 |
commit | 386c375ab9990326eb7b0454cf09090686f8eba3 (patch) | |
tree | 1bc6c97d979763f7844bff616872e85f55f1341b /layouts | |
parent | 6377a1c909140bd120d94391a00cf7e5bda3409d (diff) |
Add pagination
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/list.html | 3 | ||||
-rw-r--r-- | layouts/partials/pagination.html | 27 |
2 files changed, 29 insertions, 1 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 00884f6..392c5e2 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -2,7 +2,7 @@ <article> <h1>{{ .Title }}</h1> <ul class="posts-list"> - {{ range $index, $element := $.Paginator.Pages }} + {{ range $index, $element := .Paginator.Pages }} <li class="posts-list-item"> <a class="posts-list-item-title" href="{{ .Permalink }}">{{ .Title }}</a> <span class="posts-list-item-description"> @@ -12,5 +12,6 @@ </li> {{ end }} </ul> + {{ partial "pagination.html" $ }} </article> {{ end }} diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html new file mode 100644 index 0000000..be6fa11 --- /dev/null +++ b/layouts/partials/pagination.html @@ -0,0 +1,27 @@ +{{ with $.Paginator }} +{{ if gt .TotalPages 1 }} +<ul class="pagination"> + {{ with .Prev }} + <li class="page-item"> + <a class="page-link" href="{{ .URL }}"> + {{ partial "icon.html" (dict "ctx" $ "name" "arrow-left") }} + </a> + </li> + {{ end }} + {{ range .Pagers }} + <li class="page-item{{ if eq .PageNumber $.Paginator.PageNumber }} active{{ end }}"> + <a class="page-link" href="{{ .URL }}"> + {{ .PageNumber }} + </a> + </li> + {{ end }} + {{ with .Next }} + <li class="page-item"> + <a class="page-link" href="{{ .URL }}"> + {{ partial "icon.html" (dict "ctx" $ "name" "arrow-right") }} + </a> + </li> + {{ end }} +</ul> +{{ end }} +{{ end }} |