diff options
author | pavel <pavel.post@deutschebahn.com> | 2020-04-19 22:45:00 +0300 |
---|---|---|
committer | pavel <pavel.post@deutschebahn.com> | 2020-04-19 22:45:00 +0300 |
commit | d9e56abfa3b4a817c3b1b377b629bd6b4729e1f6 (patch) | |
tree | 1c87507c899d83cf233e1157d4c2dded7ed51bdb | |
parent | 9bfb62340332d8ee5ef0dab996f5a60b683f7ff0 (diff) |
display sections only if content is provided
-rw-r--r-- | exampleSite/config.toml | 1 | ||||
-rw-r--r-- | layouts/_default/list.html | 18 |
2 files changed, 14 insertions, 5 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index a8331c3..5e99845 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -14,7 +14,6 @@ defaultContentLanguage = "en" weight = 1 [params.microblog] -enable = true number = 2 [params.assets] diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 238f126..defe6ad 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -6,7 +6,11 @@ <!-- Microblog Area --> -{{ if .Site.Params.microblog.enable }} + +<!-- only show section if at least one microblog post --> +{{ $microposts := (where .Site.RegularPages "Section" "==" "micro") }} +{{ if ge (len $microposts) 1 }} + <section class="section-highlight"> <div class ="container"> @@ -14,7 +18,7 @@ <a href="/micro"><h2 class="areatitle">{{ i18n "microblog_title" }}</h2></a> <!-- show "number" of latest "micro" type articles --> - {{ range first .Site.Params.microblog.number (where .Site.RegularPages.ByDate.Reverse "Type" "in" "micro") }} + {{ range first .Site.Params.microblog.number (where .Site.RegularPages.ByDate.Reverse "Section" "==" "micro") }} <!-- Article Tags --> <div class="subtitle tags is-6 is-pulled-right"> @@ -47,16 +51,21 @@ </section> {{ end }} + <!-- Blog Area --> + +<!-- only show section if at least one blog post --> +{{ $blogposts := (where .Site.RegularPages "Section" "==" "blog") }} +{{ if ge (len $blogposts) 1 }} + <section class="section"> <div class="container"> - <a href="/blog"><h2 class="areatitle">{{ i18n "blog_title" }}</h2></a> <!-- Loop through all posts filtered by type "article" --> - {{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Type" "in" "blog") }} + {{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "==" "blog") }} {{ range .Paginator.Pages }} <article> @@ -103,6 +112,7 @@ </div> </section> +{{ end }} |