Add best posts and group by date

This commit is contained in:
Alexis Tacnet
2017-02-12 17:58:16 +01:00
parent e02bf39694
commit f0527ffada
6 changed files with 45 additions and 22 deletions

View File

@@ -10,16 +10,18 @@
{{ end }}
{{ end }}
</div>
<div class="posts">
{{ if ne (len (where .Data.Pages "Title" "!=" $globalTitle)) 0}}
<div class="page-heading">{{ .Title }}</div>
<ul>
{{ range .Data.Pages.ByPublishDate }}
{{ if ne .Title $globalTitle }}
{{ partial "li.html" . }}
<div class="page-heading">{{ .Title }}</div>
<ul>
{{ range .Data.Pages.ByPublishDate }}
{{ if ne .Title $globalTitle }}
{{ partial "li.html" . }}
{{ end }}
{{ end }}
{{ end }}
</ul>
</ul>
{{ end }}
</div>
</div>
</div>
</section>

View File

@@ -8,12 +8,16 @@
</div>
{{ end }}
<div class="posts">
{{ $nbPosts := len (where .Data.Pages "Section" "blog") }}
{{ if gt $nbPosts 0 }}
<div class="page-heading">Latest posts</div>
<ul>
{{ range first .Site.Params.latestpostcount (where .Data.Pages "Section" "blog") }}
{{ partial "li.html" . }}
{{ range (first .Site.Params.latestpostcount (where .Pages "Section" "blog")).GroupByDate "Jan, 2006" "desc" }}
<li class="groupby">{{ .Key }}</li>
{{ range .Pages.ByPublishDate }}
{{ partial "li.html" . }}
{{ end }}
{{ end }}
</ul>
@@ -21,6 +25,21 @@
<a href="./blog/" class="see-more">See more ...</a>
{{ end }}
{{ end }}
</div>
<div class="posts">
{{ $nbPosts := len (where .Data.Pages "Params.best" true) }}
{{ if gt $nbPosts 0 }}
<div class="page-heading">Best posts</div>
<ul>
{{ range .Data.Pages.ByPublishDate }}
{{ if eq .Params.best true }}
{{ partial "li.html" . }}
{{ end }}
{{ end }}
</ul>
{{ end }}
</div>
</div>
</div>
</section>

View File

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