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

@@ -22,7 +22,7 @@ logofile = "img/logo.png"
faviconfile = "img/logo.png" faviconfile = "img/logo.png"
highlightjs = true highlightjs = true
progressively = true progressively = true
latestpostcount = 10 latestpostcount = 5
lang = "en" lang = "en"
github = "example" github = "example"
email = "you@example.com" email = "you@example.com"

View File

@@ -2,6 +2,7 @@
author: "Alexis Tacnet" author: "Alexis Tacnet"
date: 2015-09-28 date: 2015-09-28
title: Example article title: Example article
best: true
--- ---
## Text ## Text

View File

@@ -10,6 +10,7 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
</div> </div>
<div class="posts">
{{ if ne (len (where .Data.Pages "Title" "!=" $globalTitle)) 0}} {{ if ne (len (where .Data.Pages "Title" "!=" $globalTitle)) 0}}
<div class="page-heading">{{ .Title }}</div> <div class="page-heading">{{ .Title }}</div>
<ul> <ul>
@@ -22,5 +23,6 @@
{{ end }} {{ end }}
</div> </div>
</div> </div>
</div>
</section> </section>
{{ partial "footer.html" . }} {{ partial "footer.html" . }}

View File

@@ -8,13 +8,17 @@
</div> </div>
{{ end }} {{ end }}
<div class="posts">
{{ $nbPosts := len (where .Data.Pages "Section" "blog") }} {{ $nbPosts := len (where .Data.Pages "Section" "blog") }}
{{ if gt $nbPosts 0 }} {{ if gt $nbPosts 0 }}
<div class="page-heading">Latest posts</div> <div class="page-heading">Latest posts</div>
<ul> <ul>
{{ range first .Site.Params.latestpostcount (where .Data.Pages "Section" "blog") }} {{ range (first .Site.Params.latestpostcount (where .Pages "Section" "blog")).GroupByDate "Jan, 2006" "desc" }}
<li class="groupby">{{ .Key }}</li>
{{ range .Pages.ByPublishDate }}
{{ partial "li.html" . }} {{ partial "li.html" . }}
{{ end }} {{ end }}
{{ end }}
</ul> </ul>
{{ if gt $nbPosts .Site.Params.latestpostcount }} {{ if gt $nbPosts .Site.Params.latestpostcount }}
@@ -22,6 +26,21 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
</div> </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> </div>
</section> </section>
{{ partial "footer.html" . }} {{ partial "footer.html" . }}

View File

@@ -2,6 +2,7 @@
<section class="main"> <section class="main">
<div class="container"> <div class="container">
<div class="content"> <div class="content">
<div class="posts">
<div class="page-heading">Blog</div> <div class="page-heading">Blog</div>
<ul> <ul>
{{ range .Data.Pages.GroupByDate "Jan, 2006" "desc"}} {{ range .Data.Pages.GroupByDate "Jan, 2006" "desc"}}
@@ -13,5 +14,6 @@
</ul> </ul>
</div> </div>
</div> </div>
</div>
</section> </section>
{{ partial "footer.html" . }} {{ partial "footer.html" . }}

View File

@@ -495,6 +495,9 @@ section.main .content .title-container {
-ms-justify-content: space-between; -ms-justify-content: space-between;
justify-content: space-between; justify-content: space-between;
} }
section.main .content .posts {
margin-bottom: 4em;
}
section.main .content .page-heading { section.main .content .page-heading {
font-size: 18px; font-size: 18px;
font-family: 'Raleway', 'Helvetica Neue', 'Arial', sans-serif; font-family: 'Raleway', 'Helvetica Neue', 'Arial', sans-serif;
@@ -637,9 +640,6 @@ section.header {
section.header-home { section.header-home {
padding-top: 36px; padding-top: 36px;
} }
section.icons {
padding-top: 0;
}
section.main { section.main {
padding-top: 32px; padding-top: 32px;
padding-bottom: 32px; padding-bottom: 32px;
@@ -660,7 +660,6 @@ section.main .container .content .post-item {
padding-bottom: 60px; padding-bottom: 60px;
} }
section.icons { section.icons {
padding-top: 60px;
padding-bottom: 60px; padding-bottom: 60px;
} }
section.main { section.main {