From ceacb8701ce3576802367960ce3c357c43d9b154 Mon Sep 17 00:00:00 2001 From: mogimogitomato Date: Sun, 15 Dec 2019 01:42:28 +0900 Subject: add taxonomies counter --- README.md | 1 + exampleSite/config.toml | 1 + layouts/index.html | 2 +- layouts/partials/taxonomies_count.html | 13 +++++++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/taxonomies_count.html diff --git a/README.md b/README.md index 6e4d55e..3b2f3ef 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ homeTitle = "" # Title for home page poweredby = true # Adds powered by hugo and kiss below Copyright related = true # Includes related articles at the bottom of the article codeCopy = true # Add copy button above code blocks +taxonomiesCount = true # Add taxonomies count [params.features] disqusOnDemand = true # Load Disqus comments on click diff --git a/exampleSite/config.toml b/exampleSite/config.toml index cf5546e..4d2d55b 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -27,6 +27,7 @@ enableSocial = false # Adds OpenGraph and Twitter cards homeTitle = "" # Title for home page poweredby = true # Adds powered by Hugo and Kiss below Copyright section related = true # Includes related articles +taxonomiesCount = true # Add taxonomies count [params.opengraph.facebook] admins = [] # array of Facebook IDs diff --git a/layouts/index.html b/layouts/index.html index 14da1f4..526534b 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -14,7 +14,7 @@ {{ end }}

{{ .Date.Format "January 2, 2006" }}

-

{{ .Title }}{{ if .Draft }} ::Draft{{ end }}

+

{{ .Title }}{{ partial "taxonomies_count" . }}{{ if .Draft }} ::Draft{{ end }}

{{ .Summary | plainify | safeHTML }} {{ if .Truncated }} diff --git a/layouts/partials/taxonomies_count.html b/layouts/partials/taxonomies_count.html new file mode 100644 index 0000000..a17590d --- /dev/null +++ b/layouts/partials/taxonomies_count.html @@ -0,0 +1,13 @@ +{{if .Site.Params.Info.taxonomiesCount}} +{{ $title := urlize .Title }} + {{ range $taxonomy_name, $taxonomy := .Site.Taxonomies }} + {{ if eq $.Section $taxonomy_name}} + {{ range $key, $value := $taxonomy }} + {{ $term := urlize $key }} + {{ if eq $title $term }} + ({{ $value.Count }}) + {{ end }} + {{ end }} + {{ end }} + {{ end }} +{{ end }} \ No newline at end of file -- cgit v1.2.3