diff --git a/post_archive/README.md b/post_archive/README.md new file mode 100644 index 0000000..58a8309 --- /dev/null +++ b/post_archive/README.md @@ -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) \ No newline at end of file diff --git a/post_archive/content/archive.md b/post_archive/content/archive.md new file mode 100644 index 0000000..7482b34 --- /dev/null +++ b/post_archive/content/archive.md @@ -0,0 +1,7 @@ ++++ +title = "Archives" +summary = "All my Posts ordered by their publication date." +draft = false ++++ + +{{% archive %}} \ No newline at end of file diff --git a/post_archive/post_archive.png b/post_archive/post_archive.png new file mode 100644 index 0000000..af7cb3c Binary files /dev/null and b/post_archive/post_archive.png differ diff --git a/post_archive/shortcodes/archive.html b/post_archive/shortcodes/archive.html new file mode 100644 index 0000000..468de9d --- /dev/null +++ b/post_archive/shortcodes/archive.html @@ -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}}) + +
+ + {{.Summary}} + +
+ +{{ $prev = .Date.Format "2006"}} +{{end}} +{{end}}