Merge pull request #18 from ch3nnn/main

feat: support divide post list by year
This commit is contained in:
Hanwen Guo 2024-09-22 12:46:03 -06:00 committed by GitHub
commit 6cd4ade998
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -33,3 +33,4 @@
appearance = "auto"
back_home_text = ".."
date_format = "2006-01-02"
isListGroupByDate = false

View File

@ -4,5 +4,19 @@
<h1>{{ .Title }}</h1>
{{ .Content }}
<!-- divide post list by year -->
{{ if .Site.Params.theme_config.isListGroupByDate }}
{{ range .Pages.GroupByDate "2006 Year" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ else }}
{{ partial "post_list.html" (dict "context" . "section" .Section)}}
{{ end }}
{{ end }}