Skip to content

Commit

Permalink
feat: Pagination (#338)
Browse files Browse the repository at this point in the history
Close #254
  • Loading branch information
peaceiris authored May 9, 2021
1 parent 06a5402 commit 57b2236
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/theme/scss/bulma.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $dropdown-item-color: $grey-lighter;
// @import "../../mod/bulma/components/message.sass";
@import "../../mod/bulma/components/modal.sass";
@import "../../mod/bulma/components/navbar.sass";
// @import "../../mod/bulma/components/pagination.sass";
@import "../../mod/bulma/components/pagination.sass";
// @import "../../mod/bulma/components/panel.sass";
// @import "../../mod/bulma/components/tabs.sass";

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/config/_default/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module:
# googleAnalytics: UA-123-45
disqusShortname: hugothemeiris

# paginate: 3
paginate: 3
canonifyURLs: true
enableRobotsTXT: true
pluralizeListTitles: false
Expand Down
33 changes: 30 additions & 3 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

<main>
<article>
<!-- "{{.Content}}" pulls from the markdown content of the corresponding _index.md -->
<section class="section">
{{ partial "content" . }}
</section>
</article>
<!-- Ranges through content/posts/*.md -->
{{ range .Pages }}

{{ $paginator := .Paginate .Pages }}

{{ range $paginator.Pages }}
<div class="columns">
<div class="column is-10-tablet is-offset-1-tablet is-8-desktop is-offset-2-desktop">
<a href="{{ .Permalink }}" class="normal-link">
Expand Down Expand Up @@ -45,6 +46,32 @@ <h2 class="title">{{ $title }}</h2>
</div>
</div>
{{ end }}

<section class="section">
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
{{ if $paginator.HasPrev }}
<a class="pagination-previous" href="{{ $paginator.Prev.URL | relLangURL }}">Previous</a>
{{ end }}
{{ if $paginator.HasNext }}
<a class="pagination-next" href="{{ $paginator.Next.URL | relLangURL }}">Next</a>
{{ end }}
<ul class="pagination-list">
{{ if ne $paginator.PageNumber 1 }}
<li><a href="{{ $paginator.First.URL | relLangURL }}" class="pagination-link" aria-label="Goto page 1">{{ $paginator.First.PageNumber }}</a></li>
{{ if gt $paginator.PageNumber 2 }}
<li><span class="pagination-ellipsis">&hellip;</span></li>
{{ end }}
{{ end }}
<li><a href="#!" class="pagination-link is-current" aria-label="Page {{ $paginator.PageNumber }}" aria-current="page">{{ $paginator.PageNumber }}</a></li>
{{ if ne $paginator.PageNumber $paginator.TotalPages }}
{{ if ne (sub $paginator.TotalPages 1) $paginator.PageNumber }}
<li><span class="pagination-ellipsis">&hellip;</span></li>
{{ end }}
<li><a href="{{ $paginator.Last.URL | relLangURL }}" class="pagination-link" aria-label="Goto page {{ $paginator.Last.PageNumber }}">{{ $paginator.Last.PageNumber }}</a></li>
{{ end }}
</ul>
</nav>
</section>
</main>

{{ if and $math $hasDollar }}
Expand Down

Large diffs are not rendered by default.

0 comments on commit 57b2236

Please sign in to comment.