diff options
author | Matt.Wang <mattwang44@gmail.com> | 2021-08-19 20:26:49 +0300 |
---|---|---|
committer | zhaohuabing <zhaohuabing@gmail.com> | 2021-08-28 05:50:20 +0300 |
commit | 9f65b08458d08770a3f919b1ca3617be523b1bd5 (patch) | |
tree | 8067c982587994801ea06c0a57628cc15cfd7071 | |
parent | f983cbba47ae2332a7b5e87667ea75634e5af5a6 (diff) |
feat: implement posts archiving page
-rw-r--r-- | exampleSite/config.toml | 3 | ||||
-rw-r--r-- | exampleSite/content/top/archive.md | 6 | ||||
-rw-r--r-- | layouts/_default/archive.html | 45 |
3 files changed, 54 insertions, 0 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 8e5fb34..b2c05fa 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -103,6 +103,9 @@ home = ["HTML", "RSS", "Algolia"] title = "BOOKS" href = "/top/books/" [[params.addtional_menus]] + title = "ARCHIVE" + href = "/top/archive/" + [[params.addtional_menus]] title = "ABOUT" href = "/top/about/" diff --git a/exampleSite/content/top/archive.md b/exampleSite/content/top/archive.md new file mode 100644 index 0000000..e9e1402 --- /dev/null +++ b/exampleSite/content/top/archive.md @@ -0,0 +1,6 @@ +--- +title: "Posts Archive" +layout: archive +type: post +description: Archive of historical posts. +---
\ No newline at end of file diff --git a/layouts/_default/archive.html b/layouts/_default/archive.html new file mode 100644 index 0000000..4a1bbf0 --- /dev/null +++ b/layouts/_default/archive.html @@ -0,0 +1,45 @@ +{{ define "main" }} +{{ $pages := (where (where .Site.Pages "Type" "post") "IsPage" true) }} + +<div class="container"> + <div class="row"> + <div class=" + col-lg-8 col-lg-offset-1 + col-md-8 col-md-offset-1 + col-sm-12 + col-xs-12 + post-container + "> + <div class="archive-list"> + {{ range ($pages.GroupByDate "2006") }} + {{ if gt .Key 1 }} + {{ $.Scratch.Set "count" 1 }} + {{ range .Pages }} + {{ if (eq ($.Scratch.Get "count") 1) }} + {{ $.Scratch.Set "count" 0 }} + <h1 class="title is-4 has-text-weight-normal">{{ .Date.Format "2006" }}</h1> + {{ end }} + {{ end }} + + <ul> + {{ range .Pages }} + <li> + <span>{{ .Date.Format "01/02" }}</span> — + <a href="{{ .RelPermalink }}"> + {{ .Title }} + </a> + </li> + {{ end }} + </ul> + + {{ end }} + {{ end }} + </div> + </div> + {{ partial "sidebar.html" . }} + </div> +</div> + + +<hr /> +{{ end }}
\ No newline at end of file |