Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

New boolean param for user to choose to hide empty stats #176

Merged
merged 4 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ disableLanguages = []
readingTime = true
imageStretch = ""
socialShare = ["twitter", "facebook", "reddit", "linkedin", "pinterest", "email"]
hideEmptyStats = true # if no Category or no Tag, hide it
pacollins marked this conversation as resolved.
Show resolved Hide resolved

[params.meta]
description = "A theme by HTML5 UP, ported by Julio Pescador. Slimmed and enhanced by Patrick Collins. Multilingual by StatnMap. Powered by Hugo."
Expand Down
26 changes: 16 additions & 10 deletions layouts/_default/stats.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
<div class="stats">
<ul class="categories">
{{ if isset .Params "categories" }}
{{ if or (and (eq .Site.Params.hideEmptyStats true) (isset .Params "categories")) (and (eq .Site.Params.hideEmptyStats false) (isset .Params "categories")) }}
<ul class="categories">
{{ if gt (len .Params.categories) 0 }}
{{ range .Params.categories }}
<li><a class="article-terms-link" href="{{ path.Join "categories" (. | urlize | lower) | relLangURL }}/">{{ . }}</a></li>
{{ end }}
{{ end }}
{{ else }}
</ul>
{{ else if and (eq .Site.Params.hideEmptyStats true) (not (isset .Params "categories")) }}
{{ else if and (eq .Site.Params.hideEmptyStats false) (not (isset .Params "categories")) }}
<ul class="categories">
<li>None</li>
{{ end }}
</ul>
<ul class="tags">
{{ if isset .Params "tags" }}
</ul>
{{ end }}
{{ if or (and (eq .Site.Params.hideEmptyStats true) (isset .Params "tags")) ( and (eq .Site.Params.hideEmptyStats false) (isset .Params "tags")) }}
<ul class="tags">
{{ if gt (len .Params.tags) 0 }}
{{ range .Params.tags }}
<li><a class="article-terms-link" href="{{ path.Join "tags" (. | urlize | lower) | relLangURL }}/">{{ . }}</a></li>
{{ end }}
{{ end }}
{{ else }}
</ul>
{{ else if and (eq .Site.Params.hideEmptyStats true) (not (isset .Params "tags")) }}
{{ else if and (eq .Site.Params.hideEmptyStats false) (not (isset .Params "tags")) }}
<ul class="tags">
<li>None</li>
{{ end }}
</ul>
</ul>
{{ end }}
</div>
pacollins marked this conversation as resolved.
Show resolved Hide resolved