From 990015ea565abbf4606d58ae890ec0ad2948440f Mon Sep 17 00:00:00 2001 From: ch3nnn Date: Fri, 22 Mar 2024 15:49:05 +0800 Subject: [PATCH] feat: support divide post list by year --- README.md | 4 ++++ config.toml | 1 + layouts/posts/list.html | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d4d22f..ed3d99f 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,10 @@ Another thing you can do to customize the index page is show the description of You can add a table of contents by supplying the `toc: true` param to your post front matter. If you want a border around it you can also set `tocBorder: true`. The toc style behavior is handled by Goldmark and the defaults can be found in the `config.toml` file. +### Posts list group by date in descending order. + +just edit `config.toml` and change `params.theme_config.isListGroupByDate` to `true`. + ### Pro tips #### Dark mode for images diff --git a/config.toml b/config.toml index 95ad262..70f42a6 100644 --- a/config.toml +++ b/config.toml @@ -33,3 +33,4 @@ appearance = "auto" back_home_text = ".." date_format = "2006-01-02" + isListGroupByDate = false diff --git a/layouts/posts/list.html b/layouts/posts/list.html index b561c10..46a0b13 100644 --- a/layouts/posts/list.html +++ b/layouts/posts/list.html @@ -4,5 +4,19 @@

{{ .Title }}

{{ .Content }} -{{ partial "post_list.html" (dict "context" . "section" .Section)}} + + +{{ if .Site.Params.theme_config.isListGroupByDate }} + {{ range .Pages.GroupByDate "2006 Year" }} +

{{ .Key }}

+ + {{ end }} +{{ else }} + {{ partial "post_list.html" (dict "context" . "section" .Section)}} +{{ end }} + {{ end }} \ No newline at end of file