summaryrefslogtreecommitdiff
path: root/layouts/_default
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-04-25 22:50:05 +0800
committerEltrac <hi@guhub.cn>2025-04-25 22:50:05 +0800
commit190312f35c50ee0726e213ea0297ead16bd52d3e (patch)
treee526a4ae48ea6c32a7d168769aa1f40cce9539a9 /layouts/_default
parent151cb94d555c5a838e22acb69fe1a7638696c3b7 (diff)
feat: open first month's post section
Diffstat (limited to 'layouts/_default')
-rw-r--r--layouts/_default/section.html69
1 files changed, 35 insertions, 34 deletions
diff --git a/layouts/_default/section.html b/layouts/_default/section.html
index d6553f28..1a0471ca 100644
--- a/layouts/_default/section.html
+++ b/layouts/_default/section.html
@@ -4,6 +4,7 @@
<div id="posts-archive" class="posts-list">
{{ partial "components/heatmap.html" . }}
<!-- Post Archive List -->
+ {{ $first := true }} <!-- 在循环外定义一次 $first 变量 -->
{{ range (where site.RegularPages "Type" "eq" "posts").GroupByDate "2006" -}}
<section class="posts-year-archive">
<h1 class="posts-year-title">
@@ -11,40 +12,40 @@
<small class="font-mono">{{ T "archivePage.postCountAnnual" (len .Pages) }}</small>
</h1>
- {{ range .Pages.GroupByDate "January" }}
- <details class="posts-month-archive">
- <summary>
- <h2 class="posts-month-title">
- {{ .Key }}
- <small class="font-mono">{{ T "archivePage.postCountMonthly" (len .Pages) }}</small>
- </h2>
- </summary>
- <div class="term-list">
- <ul class="term-list-posts">
- {{ range .Pages }}
- <li>
- <div style="display: flex; gap: 1rem;">
- <time class="font-mono">
- {{ .Date.Format "Jan 06" }}
- </time>
- <a href="{{ .Permalink }}">
- {{ .Title }}
- </a>
- </div>
- <div class="posts-item-category">
- {{ with .Params.categories }}
- <a href="/categories/{{ . }}">
- {{ . }}
- </a>
- {{ end }}
- </div>
- </li>
- {{ end }}
- </ul>
- </div>
- </details>
- {{ end }}
-
+ {{ range .Pages.GroupByDate "January" }} <!-- 这里每个月的循环 -->
+ <details class="posts-month-archive"{{ if $first }} open{{ end }}>
+ <summary>
+ <h2 class="posts-month-title">
+ {{ .Key }}
+ <small class="font-mono">{{ T "archivePage.postCountMonthly" (len .Pages) }}</small>
+ </h2>
+ </summary>
+ <div class="term-list">
+ <ul class="term-list-posts">
+ {{ range .Pages }}
+ <li>
+ <div style="display: flex; gap: 1rem;">
+ <time class="font-mono">
+ {{ .Date.Format "Jan 06" }}
+ </time>
+ <a href="{{ .Permalink }}">
+ {{ .Title }}
+ </a>
+ </div>
+ <div class="posts-item-category">
+ {{ with .Params.categories }}
+ <a href="/categories/{{ . }}">
+ {{ . }}
+ </a>
+ {{ end }}
+ </div>
+ </li>
+ {{ end }}
+ </ul>
+ </div>
+ </details>
+ {{ $first = false }} <!-- 将 $first 设置为 false 只在第一个月份显示后 -->
+ {{ end }}
</section>
{{ end }}
</div>