Skip to content

Commit 167ee1f

Browse files
committed
Use dictionary to pass whether to use a secondaryColor for the badge.
1 parent 859685f commit 167ee1f

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

layouts/partials/article-meta/basic.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,8 @@
103103
{{ if .Params.showCategories | default (.Site.Params.article.showCategories | default true) }}
104104
{{ if (eq $taxonomy "categories") }}
105105
<a class="relative mt-[0.5rem] me-2" href="{{ .RelPermalink }}">
106-
{{ if .Params.showCategoriesInSecondaryColor | default (.Site.Params.article.showCategoriesInSecondaryColor | default false) }}
107-
{{ partial "badge-secondary.html" .LinkTitle }}
108-
{{ else }}
109-
{{ partial "badge.html" .LinkTitle }}
110-
{{ end }}
106+
{{ $useSecondaryColor := .Params.showCategoriesInSecondaryColor | default (.Site.Params.article.showCategoriesInSecondaryColor | default false) }}
107+
{{ partial "badge.html" (dict "linkTitle" .LinkTitle "useSecondaryColor" $useSecondaryColor) }}
111108
</a>
112109
{{ end }}
113110
{{ end }}

layouts/partials/badge-secondary.html

Lines changed: 0 additions & 6 deletions
This file was deleted.

layouts/partials/badge.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<span class="flex cursor-pointer">
2-
<span
3-
class="rounded-md border border-primary-400 px-1 py-[1px] text-xs font-normal text-primary-700 dark:border-primary-600 dark:text-primary-400">
4-
{{ . }}
2+
{{ $linkTitle := . }}
3+
{{ $useSecondaryColor := false }}
4+
{{ if (reflect.IsMap . ) }}
5+
{{ $linkTitle = .linkTitle }}
6+
{{ $useSecondaryColor = cond (not .useSecondaryColor) false .useSecondaryColor }}
7+
{{ end }}
8+
{{ if $useSecondaryColor }}
9+
<span
10+
class="rounded-md border border-secondary-400 px-1 py-[1px] text-xs font-normal text-secondary-700 dark:border-secondary-600 dark:text-secondary-400">
11+
{{ else }}
12+
<span
13+
class="rounded-md border border-primary-400 px-1 py-[1px] text-xs font-normal text-primary-700 dark:border-primary-600 dark:text-primary-400">
14+
{{ end }}
15+
{{ $linkTitle }}
516
</span>
617
</span>

0 commit comments

Comments
 (0)