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" faviconfile = "img/logo.png"
highlightjs = true highlightjs = true
progressively = true progressively = true
latestpostcount = 10
lang = "en" lang = "en"
github = "example" github = "example"
email = "you@example.com" email = "you@example.com"

View File

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