diff options
| author | Eltrac <hi@guhub.cn> | 2025-06-07 02:50:09 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-06-07 02:50:09 +0800 |
| commit | f8f728edbfeecdfeb5e7b3f61994af6028a01680 (patch) | |
| tree | c26c78a7ebbbd86b3312627a431e95545a367a69 /layouts/_default/section.html | |
| parent | 0660eba2d965e07e72496616ff3527aa6d2dd506 (diff) | |
| parent | 2108c84a3efdbd1d0583283fa53bc9851e3a5e63 (diff) | |
Merge branch 'master' of https://github.com/BigCoke233/geek-death-project
Former-commit-id: 92b9414863c95a4b034ca2687ab326484af52496
Diffstat (limited to 'layouts/_default/section.html')
| -rw-r--r-- | layouts/_default/section.html | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/layouts/_default/section.html b/layouts/_default/section.html index d1ad5401..c051990e 100644 --- a/layouts/_default/section.html +++ b/layouts/_default/section.html @@ -2,9 +2,8 @@ <article class="posts"> {{ partial "header.html" . }} <div id="posts-archive" class="posts-list"> - {{ partial "components/wordCountChart.html" . }} <!-- Post Archive List --> - {{ $first := true }} <!-- 在循环外定义一次 $first 变量 --> + {{ $remainingMonthsToOpen := 3 }} {{ range (where site.RegularPages "Type" "eq" "posts").GroupByDate "2006" -}} <section class="posts-year-archive"> <h1 class="posts-year-title"> @@ -12,8 +11,8 @@ <small class="font-mono">{{ T "archivePage.postCountAnnual" (len .Pages) }}</small> </h1> - {{ range .Pages.GroupByDate "January" }} <!-- 这里每个月的循环 --> - <details class="posts-month-archive"{{ if $first }} open{{ end }}> + {{ range .Pages.GroupByDate "January" }} + <details class="posts-month-archive"{{ if gt $remainingMonthsToOpen 0 }} open{{ end }}> <summary> <h2 class="posts-month-title"> {{ .Key }} @@ -44,7 +43,7 @@ </ul> </div> </details> - {{ $first = false }} <!-- 将 $first 设置为 false 只在第一个月份显示后 --> + {{ $remainingMonthsToOpen = sub $remainingMonthsToOpen 1 }} {{ end }} </section> {{ end }} |
