Changed blog view on home page.

* Removed date grouping of recent blog posts.
* Added a paramter to specify how many posts to show.
This commit is contained in:
Jeff Henson
2017-02-11 11:45:51 -07:00
committed by Alexis Tacnet
parent 436ab5acb2
commit e02bf39694
2 changed files with 11 additions and 13 deletions

View File

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

View File

@@ -2,28 +2,25 @@
<section class="main">
<div class="container">
<div class="content">
{{ range where .Data.Pages "Title" "Home"}}
{{ range where .Data.Pages "Title" "Home" }}
<div class="markdown">
{{ .Content }}
</div>
{{ end }}
{{ $nbPosts := len (where .Data.Pages "Section" "blog") }}
{{ if gt $nbPosts 0 }}
<div class="page-heading">Latest posts</div>
<ul>
{{ range first 5 (.Data.Pages.GroupByDate "Jan, 2006" "desc")}}
{{ $nbPages := len (where .Pages "Section" "blog")}}
{{ if ne $nbPages 0}}
<li class="groupby">{{ .Key }}</li>
{{ end }}
{{ range where .Pages.ByPublishDate "Section" "blog"}}
{{ range first .Site.Params.latestpostcount (where .Data.Pages "Section" "blog") }}
{{ partial "li.html" . }}
{{ end }}
{{ end }}
</ul>
{{ $nbTotalGroup := len (.Data.Pages.GroupByDate "Jan, 2006" "desc")}}
{{ if gt $nbTotalGroup 5}}
{{ if gt $nbPosts .Site.Params.latestpostcount }}
<a href="./blog/" class="see-more">See more ...</a>
{{ end }}
{{ end }}
</div>
</div>
</section>