add post archive

This commit is contained in:
Kim Oliver Drechsel 2022-01-14 15:45:24 +01:00
parent 77e30f5346
commit 7299a89578
Signed by: Kim
GPG Key ID: B9D907EF02605A07
4 changed files with 55 additions and 0 deletions

31
post_archive/README.md Normal file
View File

@ -0,0 +1,31 @@
# Post Archive in Hugo
## Install
1. Add the shortcode file `shortcodes/archive.html` to your project > `layouts/shortcodes`
2. Add `content/archive.md` to your project's `/content` directory
## Usage
To reach your Archive you can add a new menu entry that links to it:
```toml
[menu]
[[menu.main]]
identifier = "about"
name = "About"
url = "/about/"
```
Add a summary (description) to each Post:
```yaml
+++
...
summary = "This is a Test Page for this Usage example"
...
+++
```
## Preview
![Highlight Boxes in Hugo](post_archive.png)

View File

@ -0,0 +1,7 @@
+++
title = "Archives"
summary = "All my Posts ordered by their publication date."
draft = false
+++
{{% archive %}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -0,0 +1,17 @@
{{ $prev := 3000}}
{{range where .Site.RegularPages "Section" "posts"}}
{{if .Date}}
{{if gt $prev (.Date.Format "2006")}}
## {{ .Date.Format "2006" }}
{{end}}
{{.Date.Format "02. Jan"}} -- [{{.Title}}]({{.Permalink}})
<div class="post-summary">
{{.Summary}}
</div>
{{ $prev = .Date.Format "2006"}}
{{end}}
{{end}}