Source of static website jo-e.de built with HUGO https://jo-e.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.8KB

  1. {{ $pag := $.Paginator }}
  2. {{ if gt $pag.TotalPages 1 }}
  3. <ul class="pagination">
  4. {{ with $pag.First }}
  5. <li class="page-item">
  6. <a href="{{ .URL }}" class="page-link" aria-label="First"><span aria-hidden="true">&laquo;&laquo;</span></a>
  7. </li>
  8. {{ end }}
  9. <li class="page-item{{ if not $pag.HasPrev }} disabled{{ end }}">
  10. <a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" class="page-link" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
  11. </li>
  12. {{ $.Scratch.Set "__paginator.ellipsed" false }}
  13. {{ range $pag.Pagers }}
  14. {{ $right := sub .TotalPages .PageNumber }}
  15. {{ $showNumber := or (le .PageNumber 3) (eq $right 0) }}
  16. {{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
  17. {{ if $showNumber }}
  18. {{ $.Scratch.Set "__paginator.ellipsed" false }}
  19. {{ $.Scratch.Set "__paginator.shouldEllipse" false }}
  20. {{ else }}
  21. {{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }}
  22. {{ $.Scratch.Set "__paginator.ellipsed" true }}
  23. {{ end }}
  24. {{ if $showNumber }}
  25. <li class="page-item{{ if eq . $pag }} active{{ end }}"><a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a></li>
  26. {{ else if ($.Scratch.Get "__paginator.shouldEllipse") }}
  27. <li class="page-item disabled"><span aria-hidden="true">&nbsp;&hellip;&nbsp;</span></li>
  28. {{ end }}
  29. {{ end }}
  30. <li class="page-item{{ if not $pag.HasNext }} disabled{{ end }}">
  31. <a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" class="page-link" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
  32. </li>
  33. {{ with $pag.Last }}
  34. <li class="page-item">
  35. <a href="{{ .URL }}" class="page-link" aria-label="Last"><span aria-hidden="true">&raquo;&raquo;</span></a>
  36. </li>
  37. {{ end }}
  38. </ul>
  39. {{ end }}