Skip to content

Commit

Permalink
fix(paginate): paginate error for empty content (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored May 12, 2020
1 parent 13b051b commit 7d0603e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
38 changes: 20 additions & 18 deletions layouts/_default/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@ <h2 class="single-title animated pulse faster">
</h2>

{{- /* Paginate */ -}}
{{- $pages := .Pages.GroupByDate "2006" -}}
{{- with .Site.Params.section.paginate | default .Site.Params.paginate -}}
{{- $pages = $.Paginate $pages . -}}
{{- else -}}
{{- $pages = .Paginate $pages -}}
{{- end -}}
{{- range $pages.PageGroups -}}
<h3 class="group-title">{{ .Key }}</h3>
{{- range .Pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
{{- .Title -}}
</a>
<span class="archive-item-date">
{{- .Date.Format ($.Site.Params.section.dateFormat | default "01-02") -}}
</span>
</article>
{{- if .Pages -}}
{{- $pages := .Pages.GroupByDate "2006" -}}
{{- with .Site.Params.section.paginate | default .Site.Params.paginate -}}
{{- $pages = $.Paginate $pages . -}}
{{- else -}}
{{- $pages = .Paginate $pages -}}
{{- end -}}
{{- range $pages.PageGroups -}}
<h3 class="group-title">{{ .Key }}</h3>
{{- range .Pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
{{- .Title -}}
</a>
<span class="archive-item-date">
{{- .Date.Format ($.Site.Params.section.dateFormat | default "01-02") -}}
</span>
</article>
{{- end -}}
{{- end -}}
{{- partial "paginator.html" . -}}
{{- end -}}
{{- partial "paginator.html" . -}}
</div>
{{- end -}}
2 changes: 1 addition & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{- end -}}

{{- /* Posts */ -}}
{{- if ne .Site.Params.home.posts.enable false -}}
{{- if ne .Site.Params.home.posts.enable false | and .Site.RegularPages -}}
{{- /* Paginate */ -}}
{{- $pages := where .Site.RegularPages "Type" "posts" -}}
{{- if .Site.Params.page.hiddenFromHomePage -}}
Expand Down
38 changes: 20 additions & 18 deletions layouts/taxonomy/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ <h2 class="single-title animated pulse faster">
</h2>

{{- /* Paginate */ -}}
{{- $pages := .Pages.GroupByDate "2006" -}}
{{- with .Site.Params.list.paginate | default .Site.Params.paginate -}}
{{- $pages = $.Paginate $pages . -}}
{{- else -}}
{{- $pages = .Paginate $pages -}}
{{- end -}}
{{- range $pages.PageGroups -}}
<h3 class="group-title">{{ .Key }}</h3>
{{- range .Pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
{{- .Title -}}
</a>
<span class="archive-item-date">
{{- .Date.Format ($.Site.Params.list.dateFormat | default "01-02") -}}
</span>
</article>
{{- if .Pages -}}
{{- $pages := .Pages.GroupByDate "2006" -}}
{{- with .Site.Params.list.paginate | default .Site.Params.paginate -}}
{{- $pages = $.Paginate $pages . -}}
{{- else -}}
{{- $pages = .Paginate $pages -}}
{{- end -}}
{{- range $pages.PageGroups -}}
<h3 class="group-title">{{ .Key }}</h3>
{{- range .Pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
{{- .Title -}}
</a>
<span class="archive-item-date">
{{- .Date.Format ($.Site.Params.list.dateFormat | default "01-02") -}}
</span>
</article>
{{- end -}}
{{- end -}}
{{- partial "paginator.html" . -}}
{{- end -}}
{{- partial "paginator.html" . -}}
</div>
{{- end -}}

0 comments on commit 7d0603e

Please sign in to comment.