diff options
author | otis <xiaohei.zyx@gmail.com> | 2019-12-30 14:06:16 +0300 |
---|---|---|
committer | otis <xiaohei.zyx@gmail.com> | 2019-12-30 14:06:16 +0300 |
commit | 8539445c8305dcba8feebc420f12bc76131857ef (patch) | |
tree | a9e283a8094fa137b97594992ad02f965bcc9f22 | |
parent | 033a377ef93c8b3d0ee2852d1f01ee64c2686cff (diff) |
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 |