From 5ff6beef99eb19f28d42785c7015b6c6d79b6b1a Mon Sep 17 00:00:00 2001 From: Alexis Tacnet Date: Wed, 4 Jan 2017 13:48:52 +0100 Subject: [PATCH] Add grouping by month and year in the blog section --- layouts/index.html | 13 ++++++++++--- layouts/section/blog.html | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 layouts/section/blog.html diff --git a/layouts/index.html b/layouts/index.html index e0d6c25..47dd0e2 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -2,10 +2,17 @@
-
Blog
+ {{ range where .Data.Pages "Title" "Home"}} +
+ {{ .Content }} +
+ {{ end }} +
    - {{ range .Data.Pages.ByPublishDate }} - {{ if eq .Section "blog" }} + {{ range first 5 (.Data.Pages.GroupByDate "Jan, 2006" "desc")}} + {{ $nbPages := len (where .Pages "Section" "blog")}} + {{ if ne $nbPages 0}}{{ .Key }}{{ end }} + {{ range where .Pages.ByPublishDate "Section" "blog"}} {{ partial "li.html" . }} {{ end }} {{ end }} diff --git a/layouts/section/blog.html b/layouts/section/blog.html new file mode 100644 index 0000000..ff6baa4 --- /dev/null +++ b/layouts/section/blog.html @@ -0,0 +1,17 @@ +{{ partial "header.html" . }} +
    +
    +
    +
    Blog
    +
      + {{ range .Data.Pages.GroupByDate "Jan, 2006" "desc"}} + {{ .Key }} + {{ range .Pages.ByPublishDate }} + {{ partial "li.html" . }} + {{ end }} + {{ end }} +
    +
    +
    +
    +{{ partial "footer.html" . }}