diff options
author | yx.z <xiaohei.zyx@gmail.com> | 2019-12-30 14:07:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-30 14:07:07 +0300 |
commit | 2356158ae40813d511c67af0ec9dab3938a52799 (patch) | |
tree | 02642fa46adba4416b7de34f1e1e173097f747f5 | |
parent | d267b40468108d514d95b8767a91cf49385b2e86 (diff) | |
parent | 8539445c8305dcba8feebc420f12bc76131857ef (diff) |
Merge pull request #58 from xiaoheiAh/fix-collapse
fix collapse
-rw-r--r-- | layouts/_default/list.html | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 9ea1261..794da11 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -3,37 +3,38 @@ <article class="content article article-archives article-type-list" itemscope=""> <header class="article-header"> <h1 itemprop="title">{{ .Title }}</h1> - <p class="text-muted">{{- T "total_article" (len .Pages) }}</p> + <p class="text-muted">{{- T "total_article" (len .RegularPages) }}</p> </header> <div class="article-body"> - {{ range $idx,$page := .Pages }} - {{ $thisYear := $page.Date.Format ("2006") }} - {{- $lastElement := $idx | add -1 | index $.RegularPages }} - {{- if or (eq $idx 0) ( ne ($lastElement.Date.Format "2006") $thisYear ) }} - <section class="panel panel-default b-no"> - <div class="panel-heading" role="tab"> - <h3 class="panel-title"> - <a data-toggle="collapse" href="#collapse{{- $thisYear }}" aria-expanded="true"> - <i class="icon icon-calendar-plus text-active"></i><i class="icon icon-calendar-minus text"></i> - {{- $thisYear }} - </a> - </h3> - </div> - <div id="collapse{{- $thisYear }}" class="panel-collapse collapse in" role="tabpanel" - aria-labelledby="heading{{- $thisYear }}"> - <div class="panel-body"> - <div class="collection"> - {{- if ne $idx 0 }} - </div></div></div></section> + {{- $currentYearSection := 0}} + {{- range $idx,$page := .RegularPages}} + {{- $thisYear := $page.Date.Format ("2006") }} + {{- if eq $currentYearSection 0 }} + {{- $currentYearSection = $thisYear}} {{- end }} - {{- end }} - - {{- .Scratch.Set "type" "link"}} - {{- partial "item-post.html" . }} - - {{- end }} - </div> + {{- if or (eq $idx 0) (ne $currentYearSection $thisYear)}} + {{- if ne $idx 0 }} + </div></div></div></section> + {{- end}} + <section class="panel panel-default b-no"> + <div class="panel-heading" role="tab"> + <h3 class="panel-title"> + <a data-toggle="collapse" href="#collapse{{- $thisYear }}" aria-expanded="true"> + <i class="icon icon-calendar-plus text-active"></i><i class="icon icon-calendar-minus text"></i> + {{- $thisYear }} + </a> + </h3> + </div> + <div id="collapse{{- $thisYear }}" class="panel-collapse collapse in" role="tabpanel" + aria-labelledby="heading{{- $thisYear }}"> + <div class="panel-body"> + <div class="collection"> + {{- end}} + {{- .Scratch.Set "type" "link"}} + {{- partial "item-post.html" . }} + {{- end}} </div></div></div></section> + </div> </article> </main> {{- end }}
\ No newline at end of file |