mirror of https://github.com/lxndrblz/anatole.git

Alexander Bilz
31.06.2021 02341d0bd08e58df25c74a477aa91c53ec0ae760
feat: added prettier pagination (#247)

Co-authored-by: mousemin <mousemin@users.noreply.github.com>
2 files modified
1 files added
57 ■■■■■ changed files
assets/css/style.css 1 ●●●● patch | view | raw | blame | history
layouts/index.html 2 ●●● patch | view | raw | blame | history
layouts/partials/pagination.html 54 ●●●●● patch | view | raw | blame | history
assets/css/style.css
@@ -541,6 +541,7 @@
  margin: 30px;
  padding: 0px 0 56px 0;
  text-align: center;
  font-size: 1.4rem;
}
.pagination ul {
layouts/index.html
@@ -114,7 +114,7 @@
  {{ end }}
  <div class="pagination">
    {{ template "_internal/pagination.html" . }}
    {{ template "partials/pagination.html" . }}
  </div>
{{ end }}
layouts/partials/pagination.html
New file
@@ -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">&hellip;</span>
        {{ else if and (not ($.Scratch.Get "hasNextDots")) (gt .PageNumber $.Paginator.PageNumber) }}
          {{ $.Scratch.Set "hasNextDots" true }}
          <span class="page-link dots">&hellip;</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 }}