diff options
author | Alexander Bilz <mail@alexbilz.com> | 2021-08-31 16:06:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-31 16:06:00 +0300 |
commit | 02341d0bd08e58df25c74a477aa91c53ec0ae760 (patch) | |
tree | 92a7466ad7b543635a8ec8a62864e423566e66eb | |
parent | e1bfb62880c7a5da85b3b24fe0f02078f17b90ba (diff) | |
parent | a93f3f8e7848bad6cc70c5532b0404014e2fb711 (diff) |
feat: added prettier pagination (#247)
Co-authored-by: mousemin <mousemin@users.noreply.github.com>
-rw-r--r-- | assets/css/style.css | 1 | ||||
-rw-r--r-- | layouts/index.html | 2 | ||||
-rw-r--r-- | layouts/partials/pagination.html | 54 |
3 files changed, 56 insertions, 1 deletions
diff --git a/assets/css/style.css b/assets/css/style.css index 7e56c2b..50b2fbf 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -541,6 +541,7 @@ aside { margin: 30px; padding: 0px 0 56px 0; text-align: center; + font-size: 1.4rem; } .pagination ul { diff --git a/layouts/index.html b/layouts/index.html index 61cabf7..aa74958 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -114,7 +114,7 @@ {{ end }} <div class="pagination"> - {{ template "_internal/pagination.html" . }} + {{ template "partials/pagination.html" . }} </div> {{ end }} diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html new file mode 100644 index 0000000..a5b315c --- /dev/null +++ b/layouts/partials/pagination.html @@ -0,0 +1,54 @@ +{{ if gt .Paginator.TotalPages 1 }} + <ul class="pagination"> + {{ $.Scratch.Set "hasPrevDots" false }} + {{ $.Scratch.Set "hasNextDots" false }} + {{ if .Paginator.HasPrev }} + <li class="page-item"> + <a class="page-link" href="{{ .Paginator.Prev.URL }}"> + <i class="fa fa-angle-left" aria-label="上一页"></i> + </a> + </li> + + {{ end }} + {{ range .Paginator.Pagers }} + {{ if eq . $.Paginator }} + <li class="page-item"> + <span class="page-link current"> + {{- .PageNumber -}} + </span> + </li> + + {{ else if or (or (eq . $.Paginator.First) (eq . $.Paginator.Prev)) (or (eq . $.Paginator.Next) (eq . $.Paginator.Last )) }} + <li class="page-item"> + <a class="page-link" href="{{ .URL }}"> + {{- .PageNumber -}} + </a> + </li> + + {{ else }} + {{ if and (not ($.Scratch.Get "hasPrevDots")) (lt .PageNumber $.Paginator.PageNumber) }} + {{ $.Scratch.Set "hasPrevDots" true }} + <span class="page-link dots">…</span> + + {{ else if and (not ($.Scratch.Get "hasNextDots")) (gt .PageNumber $.Paginator.PageNumber) }} + {{ $.Scratch.Set "hasNextDots" true }} + <span class="page-link dots">…</span> + + {{ end }} + + + {{ end }} + + + {{ end }} + {{ if .Paginator.HasNext }} + <li class="page-item"> + <a class="page-link" href="{{ .Paginator.Next.URL }}"> + <i class="fa fa-angle-right" aria-label="下一页"></i> + </a> + </li> + + {{ end }} + </ul> + +{{ end }} |