add post archive
This commit is contained in:
parent
77e30f5346
commit
7299a89578
31
post_archive/README.md
Normal file
31
post_archive/README.md
Normal 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)
|
7
post_archive/content/archive.md
Normal file
7
post_archive/content/archive.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
+++
|
||||||
|
title = "Archives"
|
||||||
|
summary = "All my Posts ordered by their publication date."
|
||||||
|
draft = false
|
||||||
|
+++
|
||||||
|
|
||||||
|
{{% archive %}}
|
BIN
post_archive/post_archive.png
Normal file
BIN
post_archive/post_archive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
17
post_archive/shortcodes/archive.html
Normal file
17
post_archive/shortcodes/archive.html
Normal 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}}
|
Loading…
x
Reference in New Issue
Block a user