mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
2 days ago 677948afce4163476d8d28619190401d5892cdac
fix: show categories on posts

Add a categories.html partial that renders linked Hugo categories terms
using the same styling pattern as tags, and include it before tags on
single pages.

Add a global `ananke.show_categories` switch (default true) to toggle
the category display; set it to false to hide categories site-wide.

Closes #620
2 files modified
1 files added
14 ■■■■■ changed files
config/_default/params.toml 1 ●●●● patch | view | raw | blame | history
layouts/_partials/categories.html 12 ●●●●● patch | view | raw | blame | history
layouts/single.html 1 ●●●● patch | view | raw | blame | history
config/_default/params.toml
@@ -1,5 +1,6 @@
[ananke]
show_recent_posts = true # show recent posts on the homepage
show_categories = true # show categories terms on single pages
[ananke.home]
content_alignment = "center" # options: left, center, right
layouts/_partials/categories.html
New file
@@ -0,0 +1,12 @@
{{- /* Show category terms on single pages unless disabled via site.Params.ananke.show_categories = false */ -}}
{{- if not (eq false site.Params.ananke.show_categories) -}}
<ul class="pa0">
  {{ range .GetTerms "categories" }}
   <li class="list di">
     <a href="{{ .RelPermalink }}" class="link f5 grow br-pill ba ph3 pv2 mb2 dib black sans-serif no-underline">
       {{- .LinkTitle -}}
     </a>
   </li>
  {{ end }}
</ul>
{{- end -}}
layouts/single.html
@@ -75,6 +75,7 @@
      {{- partials.Include "hook.html" (dict "hook" "content-before" "context" .) -}}
      {{- .Content -}}
      {{- partials.Include "hook.html" (dict "hook" "content-after" "context" .) -}}
      {{- partials.Include "categories.html" . -}}
      {{- partials.Include "tags.html" . -}}
      {{ if .Site.Config.Services.Disqus.Shortname }}
      <div class="mt6 instapaper_ignoref">