mirror of
https://github.com/Noettore/cocoa-eh-hugo-theme.git
synced 2025-10-15 19:56:41 +02:00
Add grouping by month and year in the blog section
This commit is contained in:
@@ -2,10 +2,17 @@
|
|||||||
<section class="main">
|
<section class="main">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="page-heading">Blog</div>
|
{{ range where .Data.Pages "Title" "Home"}}
|
||||||
|
<div class="markdown">
|
||||||
|
{{ .Content }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{{ range .Data.Pages.ByPublishDate }}
|
{{ range first 5 (.Data.Pages.GroupByDate "Jan, 2006" "desc")}}
|
||||||
{{ if eq .Section "blog" }}
|
{{ $nbPages := len (where .Pages "Section" "blog")}}
|
||||||
|
{{ if ne $nbPages 0}}{{ .Key }}{{ end }}
|
||||||
|
{{ range where .Pages.ByPublishDate "Section" "blog"}}
|
||||||
{{ partial "li.html" . }}
|
{{ partial "li.html" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
17
layouts/section/blog.html
Normal file
17
layouts/section/blog.html
Normal 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" . }}
|
Reference in New Issue
Block a user