Skip to content

Commit

Permalink
Update pagination menu on guest page for mobile
Browse files Browse the repository at this point in the history
Fixes ##217

Signed-off-by: Matt Stratton <[email protected]>
  • Loading branch information
mattstratton committed Nov 3, 2019
1 parent 4ffb4c4 commit 6cf3f9a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 33 deletions.
12 changes: 6 additions & 6 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ paginate = "9"
[[Menu.Main]]
name = "About"
identifier = "about"
url = "about"
url = "/about"

[[Menu.Main]]
name = "Contact"
identifier = "contact"
url = "contact"
url = "/contact"

[[Menu.Main]]
name = "Hosts"
identifier = "hosts"
url = "host"
url = "/host"

[[Menu.Main]]
name = "Guests"
identifier = "guests"
url = "guest"
url = "/guest"

[[Menu.Main]]
name = "Resources"
Expand All @@ -44,12 +44,12 @@ paginate = "9"
[[Menu.Main]]
name = "Books"
identifier = "books"
url = "books"
url = "/books"
parent = "resources"
[[Menu.Main]]
name = "Podcasts"
identifier = "podcasts"
url = "books"
url = "/books"
parent = "resources"

[params]
Expand Down
76 changes: 49 additions & 27 deletions layouts/guest/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,55 @@ <h3><a href = "{{(printf "guest/%s" .File.BaseFileName) | absURL }}">{{ .Title }
{{ $.Scratch.Set "show" (seq 1 $total) }}
{{ end }}

<ul class="pagination pagination-lg">
{{- with $paginator.First -}}
{{- $url := trim (string .URL) "/" | absURL -}}
<li class="page-item">
<a href="{{ $url }}" aria-label="First" class="page-link"><span aria-hidden="true">&laquo;&laquo;</span></a>
</li>
{{- end -}}
<li class="{{ if not $paginator.HasPrev }}disabled {{ end }}page-item">
<a href="{{ if $paginator.HasPrev }}{{ $paginator.Prev.URL }}{{ end }}" aria-label="Previous" class="page-link"><span aria-hidden="true">&laquo;</span></a>
</li>

{{ range $pag.Pagers }}
{{ $cur := .PageNumber }}
{{- $url := trim (string .URL) "/" | absURL -}}
{{ if in ($.Scratch.Get "show") $cur }}
<li class = "{{ if eq . $pag }}active{{ end }} page-item"><a href="{{ .URL }}" class="page-link hidden-md-down">{{ .PageNumber }}</a></li>
{{ else if in (slice 2 (sub $total 1)) $cur }}
<li class="disabled page-item"><a name="" class="page-link hidden-md-down">&hellip;</a></li>
{{ end }}
{{ end }}
{{- with $paginator.Last -}}
{{- $url := trim (string .URL) "/" | absURL -}}
<li class="page-item">
<a href="{{ $url }}" aria-label="Last" class="page-link"><span aria-hidden="true">&raquo;&raquo;</span></a>
</li>
{{- end -}}
</ul>
<ul class="pagination pagination-lg">
<!-- first page button -->
{{if $paginator.HasPrev }}
{{ if gt $paginator.PageNumber 2 }}
{{- with $paginator.First -}}
{{- $url := trim (string .URL) "/" | absURL -}}
<li class="page-item">
<a href="{{ $url }}" aria-label="First" class="page-link"><span aria-hidden="true">&laquo;&laquo;</span></a>
</li>
{{- end -}}
{{ end }}
{{ end }}


<!-- prev page button -->
{{- with $paginator.HasPrev -}}
<li class="page-item">
<a href="{{ $paginator.Prev.URL }}" class="page-link"> &laquo; </a>
</li>
{{ end }}

<!-- page # buttons -->
{{ range $pag.Pagers }}
{{ $cur := .PageNumber }}
{{- $url := trim (string .URL) "/" | absURL -}}
{{ if in ($.Scratch.Get "show") $cur }}
<li class = "{{ if eq . $pag }}active{{ end }} page-item"><a href="{{ .URL }}" class="page-link hidden-md-down">{{ .PageNumber }}</a></li>
{{ else if in (slice 2 (sub $total 1)) $cur }}
<li class="disabled page-item"><a name="" class="page-link hidden-md-down">&hellip;</a></li>
{{ end }}
{{ end }}

<!-- next page button -->
{{- with $paginator.HasNext -}}
<li class="page-item">
<a href="{{ $paginator.Next.URL }}" class="page-link"> &raquo; </a>
</li>
{{ end }}

<!-- last page button -->
{{ if lt $paginator.PageNumber (sub $paginator.TotalPages 1) }}
{{- with $paginator.Last -}}
{{- $url := trim (string .URL) "/" | absURL -}}
<li class="page-item">
<a href="{{ $url }}" aria-label="Last" class="page-link"><span aria-hidden="true">&raquo;&raquo;</span></a>
</li>
{{- end -}}
{{ end }}
</ul>
{{ end }}
</nav>
</div>
Expand Down

0 comments on commit 6cf3f9a

Please sign in to comment.