diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-29 22:26:59 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-29 22:26:59 +0200 |
| commit | 0622836d5cb3076a6e23ed34583655c152403ca3 (patch) | |
| tree | 2154e9befa4bc5fa09bca3f19b4c2e4e0661c591 /layouts/partials | |
| parent | e10cd65cab6cfcd60f09885aa00f9bb876ca4d1e (diff) | |
| download | gohugo-theme-ed-0622836d5cb3076a6e23ed34583655c152403ca3.tar.gz | |
Add pagination support
Diffstat (limited to 'layouts/partials')
| -rw-r--r-- | layouts/partials/mini-toc.html | 9 | ||||
| -rw-r--r-- | layouts/partials/pagination.html | 33 |
2 files changed, 33 insertions, 9 deletions
diff --git a/layouts/partials/mini-toc.html b/layouts/partials/mini-toc.html index 6b52f47..0d52866 100644 --- a/layouts/partials/mini-toc.html +++ b/layouts/partials/mini-toc.html @@ -21,14 +21,5 @@ </li> {{ end }} </ul> - - {{ if gt $sectionCount $maxPosts }} - <p> - <a href="{{ "all-posts" | relURL }}"> - {{ i18n "all_publications" }} - <span aria-hidden="true">→</span> - </a> - </p> - {{ end }} </div> {{ end }} diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html new file mode 100644 index 0000000..0e675a1 --- /dev/null +++ b/layouts/partials/pagination.html @@ -0,0 +1,33 @@ +{{ if gt .Paginator.TotalPages 1 }} + <div class="divider"></div> + + <nav aria-label="pagination" class="pagination d-flex"> + <ul class="pager d-flex"> + {{ $.Scratch.Set "hasPrevDots" false }} + {{ $.Scratch.Set "hasNextDots" false }} + + {{ range .Paginator.Pagers }} + {{ $currentItem := . }} + {{ if eq $currentItem $.Paginator }} + <li class="pager-item pager-item-current"> + {{- .PageNumber -}} + </li> + {{ else if or (or (eq . $.Paginator.First) (eq . $.Paginator.Prev)) (or (eq . $.Paginator.Next) (eq . $.Paginator.Last )) }} + <li class="pager-item{{ if eq . $.Paginator.Next }} pager-item-next{{ else if eq . $.Paginator.Prev }} pager-item-prev{{ end }}"> + <a href="{{ .URL }}"{{ if eq . $.Paginator.Next }} rel="next"{{ else if eq . $.Paginator.Prev }} rel="prev"{{ end }} class="pager-link"> + {{- .PageNumber -}} + </a> + </li> + {{ else }} + {{ if and (not ($.Scratch.Get "hasPrevDots")) (lt .PageNumber $.Paginator.PageNumber) }} + {{ $.Scratch.Set "hasPrevDots" true }} + <li class='pager-item pager-item-dots'>…</li> + {{ else if and (not ($.Scratch.Get "hasNextDots")) (gt .PageNumber $.Paginator.PageNumber) }} + {{ $.Scratch.Set "hasNextDots" true }} + <li class='pager-item pager-item-dots'>…</li> + {{ end }} + {{ end }} + {{ end }} + </ul> + </nav> +{{ end }} |
