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,16 +10,18 @@
{{ 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>
{{ range .Data.Pages.ByPublishDate }} {{ range .Data.Pages.ByPublishDate }}
{{ if ne .Title $globalTitle }} {{ if ne .Title $globalTitle }}
{{ partial "li.html" . }} {{ partial "li.html" . }}
{{ end }}
{{ end }} {{ end }}
{{ end }} </ul>
</ul>
{{ end }} {{ end }}
</div>
</div> </div>
</div> </div>
</section> </section>

View File

@@ -8,12 +8,16 @@
</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" }}
{{ partial "li.html" . }} <li class="groupby">{{ .Key }}</li>
{{ range .Pages.ByPublishDate }}
{{ partial "li.html" . }}
{{ end }}
{{ end }} {{ end }}
</ul> </ul>
@@ -21,6 +25,21 @@
<a href="./blog/" class="see-more">See more ...</a> <a href="./blog/" class="see-more">See more ...</a>
{{ end }} {{ end }}
{{ 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>
</div> </div>
</section> </section>

View File

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

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 {