Add grouping by month and year in the blog section

This commit is contained in:
Alexis Tacnet
2017-01-04 13:48:52 +01:00
parent 5c5fe525d6
commit 5ff6beef99
2 changed files with 27 additions and 3 deletions

View File

@@ -2,10 +2,17 @@
<section class="main">
<div class="container">
<div class="content">
<div class="page-heading">Blog</div>
{{ range where .Data.Pages "Title" "Home"}}
<div class="markdown">
{{ .Content }}
</div>
{{ end }}
<ul>
{{ 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 }}

17
layouts/section/blog.html Normal file
View File

@@ -0,0 +1,17 @@
{{ partial "header.html" . }}
<section class="main">
<div class="container">
<div class="content">
<div class="page-heading">Blog</div>
<ul>
{{ range .Data.Pages.GroupByDate "Jan, 2006" "desc"}}
{{ .Key }}
{{ range .Pages.ByPublishDate }}
{{ partial "li.html" . }}
{{ end }}
{{ end }}
</ul>
</div>
</div>
</section>
{{ partial "footer.html" . }}