fix #314 - Archive page shows error when there are 0 posts

This commit is contained in:
zzossig 2020-10-29 22:27:37 +09:00
parent e09bbc6d4e
commit 842005439f
11 changed files with 85 additions and 49 deletions

View File

@ -114,3 +114,6 @@ other = "solarized"
[skin-kimbie]
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -113,4 +113,7 @@ other = "hacker"
other = "solarized"
[skin-kimbie]
other = "kimbie"
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -113,4 +113,7 @@ other = "hacker"
other = "solarized"
[skin-kimbie]
other = "kimbie"
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -114,3 +114,6 @@ other = "solarized"
[skin-kimbie]
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -113,4 +113,7 @@ other = "hacker"
other = "solarized"
[skin-kimbie]
other = "kimbie"
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -113,4 +113,7 @@ other = "hacker"
other = "solarized"
[skin-kimbie]
other = "kimbie"
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -113,4 +113,7 @@ other = "hacker"
other = "solarized"
[skin-kimbie]
other = "kimbie"
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -114,3 +114,6 @@ other = "solarized"
[skin-kimbie]
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -113,4 +113,7 @@ other = "hacker"
other = "solarized"
[skin-kimbie]
other = "kimbie"
other = "kimbie"
[no-contents]
other = "Nothing to Display"

View File

@ -16,27 +16,31 @@
{{ $filteredPages = (where $filteredPages "Type" "!=" (lower .)) }}
{{ end }}
{{ if gt (len $filteredPages) 0 }}
{{ $paginator := .Paginate ($filteredPages.GroupByDate ($.Param "archiveGroupByDate" | default "2006")) ($.Param "archivePaginate") }}
{{ range ($paginator).PageGroups }}
<span class="archive__key" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">{{ .Key }}</span>
<ul class="archive__ul" data-dir="{{ $.Param "languagedir" | default "ltr" }}">
{{ range .Pages }}
<li class="archive__li" data-dir="{{ $.Param "languagedir" | default "ltr" }}">
<span class="archive__meta" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">
{{ if ne ($.Param "languagedir") "rtl" }}
<span class="archive__type">{{ .Type }}</span>
<span class="archive__date">{{ .Date.Format (i18n "archive-dateformat") }}</span>
{{ else }}
<span class="archive__date">{{ .Date.Format (i18n "archive-dateformat") }}</span>
<span class="archive__type">{{ .Type }}</span>
{{ end }}
</span>
<a href="{{ .Permalink }}" class="archive__title" data-title-wrap="{{ $titleWrap | default "wrap"}}" data-dir="{{ $.Param "languagedir" | default "ltr" }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
<span class="archive__key" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">{{ .Key }}</span>
<ul class="archive__ul" data-dir="{{ $.Param "languagedir" | default "ltr" }}">
{{ range .Pages }}
<li class="archive__li" data-dir="{{ $.Param "languagedir" | default "ltr" }}">
<span class="archive__meta" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">
{{ if ne ($.Param "languagedir") "rtl" }}
<span class="archive__type">{{ .Type }}</span>
<span class="archive__date">{{ .Date.Format (i18n "archive-dateformat") }}</span>
{{ else }}
<span class="archive__date">{{ .Date.Format (i18n "archive-dateformat") }}</span>
<span class="archive__type">{{ .Type }}</span>
{{ end }}
</span>
<a href="{{ .Permalink }}" class="archive__title" data-title-wrap="{{ $titleWrap | default "wrap"}}" data-dir="{{ $.Param "languagedir" | default "ltr" }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
{{ else }}
{{ i18n "no-contents" | default "There is nothing to display" }}
{{ end }}
</div>
<div class="grow"></div>
{{ partial "pagination/pagination" . }}

View File

@ -17,34 +17,39 @@
{{ end }}
<div class="archive__container">
{{ $pages := (where .Site.RegularPages "Section" "talks") }}
{{ $paginator := .Paginate ($pages.GroupByPublishDate ($.Param "talksGroupByDate" | default "2006")) ($.Param "talksPaginate") }}
{{ range ($paginator).PageGroups }}
<span class="archive__key" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">{{ .Key }}</span>
<ul class="archive__ul" data-dir="{{ $.Param "languagedir" | default "ltr" }}">
{{ range .Pages }}
<li class="archive__li" data-dir="{{ $.Param "languagedir" | default "ltr" }}">
<span class="talk__date" data-dir="{{ $.Param "languagedir" | default "ltr" }}" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">
{{ .PublishDate.Format (i18n "talks-dateformat") }}
</span>
{{ if .Params.disableLink }}
<div class="talk__title" data-title-wrap="{{ $titleWrap | default "wrap"}}" data-dir="{{ $.Param "languagedir" | default "ltr" }}">{{ .Title }}</div>
{{ else }}
<a href="{{ if .Params.externalLink }}{{ .Params.externalLink }}{{ else }}{{ .Permalink }}{{ end }}" target="{{ with .Params.externalLink }}_blank{{ end }}" rel="{{ with .Params.externalLink }}noreferrer{{ end }}" class="talk__title" data-title-wrap="{{ $titleWrap | default "wrap"}}" data-dir="{{ $.Param "languagedir" | default "ltr" }}">{{ .Title }}</a>
{{ end }}
{{ with .Params.subLinks }}
<div class="talk__icons">
{{ range . }}
<a href="{{ .link }}" class="talk__icon" target="_blank" rel="noreferrer" title="{{ .type }}">
{{ partial (print "svgs/etc/" .type ".svg") (dict "width" 23 "height" 23) }}
</a>
{{ if gt (len $pages) 0 }}
{{ $paginator := .Paginate ($pages.GroupByPublishDate ($.Param "talksGroupByDate" | default "2006")) ($.Param "talksPaginate") }}
{{ range ($paginator).PageGroups }}
<span class="archive__key" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">{{ .Key }}</span>
<ul class="archive__ul" data-dir="{{ $.Param "languagedir" | default "ltr" }}">
{{ range .Pages }}
<li class="archive__li" data-dir="{{ $.Param "languagedir" | default "ltr" }}">
<span class="talk__date" data-dir="{{ $.Param "languagedir" | default "ltr" }}" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">
{{ .PublishDate.Format (i18n "talks-dateformat") }}
</span>
{{ if .Params.disableLink }}
<div class="talk__title" data-title-wrap="{{ $titleWrap | default "wrap"}}" data-dir="{{ $.Param "languagedir" | default "ltr" }}">{{ .Title }}</div>
{{ else }}
<a href="{{ if .Params.externalLink }}{{ .Params.externalLink }}{{ else }}{{ .Permalink }}{{ end }}" target="{{ with .Params.externalLink }}_blank{{ end }}" rel="{{ with .Params.externalLink }}noreferrer{{ end }}" class="talk__title" data-title-wrap="{{ $titleWrap | default "wrap"}}" data-dir="{{ $.Param "languagedir" | default "ltr" }}">{{ .Title }}</a>
{{ end }}
</div>
{{ end }}
</li>
{{ with .Params.subLinks }}
<div class="talk__icons">
{{ range . }}
<a href="{{ .link }}" class="talk__icon" target="_blank" rel="noreferrer" title="{{ .type }}">
{{ partial (print "svgs/etc/" .type ".svg") (dict "width" 23 "height" 23) }}
</a>
{{ end }}
</div>
{{ end }}
</li>
{{ end }}
</ul>
{{ end }}
</ul>
{{ else }}
{{ i18n "no-contents" | default "There is nothing to display" }}
{{ end }}
</div>
<div class="grow"></div>
{{ partial "pagination/pagination" . }}