Hide top posts when no orders, i18n posts-by-order

#184
fixes https://github.com/zzossig/hugo-theme-zzo/issues/184#issuecomment-588179493
This commit is contained in:
zzossig 2020-02-19 21:09:41 +09:00
parent 607bd7ceac
commit 06b1f5d4b9
5 changed files with 34 additions and 13 deletions

View File

@ -95,4 +95,7 @@ other = "Overview"
other = "Pinned"
[nojs-message]
other = "Please enable Javascript to view the contents"
other = "Please enable Javascript to view the contents"
[posts-by-order]
other = "TOP POSTS"

View File

@ -96,3 +96,6 @@ other = "پین شده"
[nojs-message]
other = "لطفا برای نمایش محتوا اجرای جاوا اسکریپت را فعال کنید"
[posts-by-order]
other = "TOP POSTS"

View File

@ -95,4 +95,7 @@ other = "개요"
other = "고정"
[nojs-message]
other = "내용을 보시려면 자바스크립트를 활성화 해주세요"
other = "내용을 보시려면 자바스크립트를 활성화 해주세요"
[posts-by-order]
other = "TOP POSTS"

View File

@ -95,4 +95,7 @@ other = "总览"
other = "固定"
[nojs-message]
other = "Please enable Javascript to view the contents"
other = "Please enable Javascript to view the contents"
[posts-by-order]
other = "TOP POSTS"

View File

@ -4,15 +4,24 @@
{{ $filteredSections = (where $filteredSections "Type" "!=" (lower .)) }}
{{ end }}
<div class="sidebar-recent__title p2">{{ i18n "posts-by-order" | default "TOP POSTS" }}</div>
<ul class="sidebar-recent__ul">
{{ range first ($.Param "itemsPerCategory") ($filteredSections.ByParam "order") }}
{{ if .Params.order }}
<li>
<a href="{{ .RelPermalink }}" class="sidebar-recent__a p2">{{ .Title }}</a>
</li>
{{ end }}
{{ $hasOrder := false }}
{{ range first ($.Param "itemsPerCategory") ($filteredSections.ByParam "order") }}
{{ if .Params.order }}
{{ $hasOrder = true }}
{{ end }}
</ul>
<hr class="hr-fade sidebar-hr" />
{{ end }}
{{ if $hasOrder }}
<div class="sidebar-recent__title p2">{{ i18n "posts-by-order" | default "TOP POSTS" }}</div>
<ul class="sidebar-recent__ul">
{{ range first ($.Param "itemsPerCategory") ($filteredSections.ByParam "order") }}
{{ if .Params.order }}
<li>
<a href="{{ .RelPermalink }}" class="sidebar-recent__a p2">{{ .Title }}</a>
</li>
{{ end }}
{{ end }}
</ul>
<hr class="hr-fade sidebar-hr" />
{{ end }}
{{ end }}