summaryrefslogtreecommitdiffstats
path: root/layouts/partials/archives-list.html
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials/archives-list.html')
-rw-r--r--layouts/partials/archives-list.html30
1 files changed, 30 insertions, 0 deletions
diff --git a/layouts/partials/archives-list.html b/layouts/partials/archives-list.html
new file mode 100644
index 0000000..b9767f7
--- /dev/null
+++ b/layouts/partials/archives-list.html
@@ -0,0 +1,30 @@
+{{ $allPages := where .Site.RegularPages "Type" "in" (slice "posts" "blog") }}
+{{ $visiblePages := where $allPages "Params.hidden" "!=" true }}
+{{ $pagesToShow := $visiblePages.ByDate.Reverse }}
+
+<div class="archives-content">
+ <h2>归档</h2>
+
+ <p>共有 {{ len $pagesToShow }} 篇文章</p>
+
+ <ul class="blog-posts">
+ {{ $currentYear := 0 }}
+ {{ range $pagesToShow }}
+ {{ $year := .Date.Year }}
+ {{ if ne $year $currentYear }}
+ <h3>{{ $year }}</h3>
+ {{ $currentYear = $year }}
+ {{ end }}
+ <li>
+ <span>
+ <i>
+ <time datetime='{{ .Date.Format "2006-01-02" }}'>
+ {{ .Date.Format "2006-01-02" }}
+ </time>
+ </i>
+ </span>
+ <a href="{{ .Permalink }}">{{ .Title }}</a>
+ </li>
+ {{ end }}
+ </ul>
+</div>