From 7d0603ece0d0e16c24063e9b30fc753ff8ac389d Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 12 May 2020 21:51:38 +0800 Subject: [PATCH] fix(paginate): paginate error for empty content (#350) --- layouts/_default/section.html | 38 ++++++++++++++++++----------------- layouts/index.html | 2 +- layouts/taxonomy/list.html | 38 ++++++++++++++++++----------------- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/layouts/_default/section.html b/layouts/_default/section.html index e81c187a6..9d07c925e 100644 --- a/layouts/_default/section.html +++ b/layouts/_default/section.html @@ -10,25 +10,27 @@

{{- /* 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 -}} -

{{ .Key }}

- {{- range .Pages -}} -
- - {{- .Title -}} - - - {{- .Date.Format ($.Site.Params.section.dateFormat | default "01-02") -}} - -
+ {{- 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 -}} +

{{ .Key }}

+ {{- range .Pages -}} +
+ + {{- .Title -}} + + + {{- .Date.Format ($.Site.Params.section.dateFormat | default "01-02") -}} + +
+ {{- end -}} {{- end -}} + {{- partial "paginator.html" . -}} {{- end -}} - {{- partial "paginator.html" . -}} {{- end -}} diff --git a/layouts/index.html b/layouts/index.html index 82da87b02..78006113d 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -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 -}} diff --git a/layouts/taxonomy/list.html b/layouts/taxonomy/list.html index 8e6d55319..249d066a5 100644 --- a/layouts/taxonomy/list.html +++ b/layouts/taxonomy/list.html @@ -17,25 +17,27 @@

{{- /* 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 -}} -

{{ .Key }}

- {{- range .Pages -}} -
- - {{- .Title -}} - - - {{- .Date.Format ($.Site.Params.list.dateFormat | default "01-02") -}} - -
+ {{- 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 -}} +

{{ .Key }}

+ {{- range .Pages -}} +
+ + {{- .Title -}} + + + {{- .Date.Format ($.Site.Params.list.dateFormat | default "01-02") -}} + +
+ {{- end -}} {{- end -}} + {{- partial "paginator.html" . -}} {{- end -}} - {{- partial "paginator.html" . -}} {{- end -}}