blowfish/layouts/partials/article-meta.html

93 lines
3.5 KiB
HTML
Raw Normal View History

2022-09-10 14:05:37 -05:00
{{/* Determine the correct context and scope */}}
{{/* This allows for different logic depending on where the partial is called */}}
{{ $context := . }}
{{ $scope := default nil }}
{{ if (reflect.IsMap . ) }}
2022-10-01 19:03:22 -05:00
{{ $context = .context }}
{{ $scope = cond (not .scope) nil .scope }}
2022-09-10 14:05:37 -05:00
{{ end }}
{{ with $context }}
2022-10-01 19:03:22 -05:00
{{ $meta := newScratch }}
2022-09-10 14:05:37 -05:00
2022-10-01 19:03:22 -05:00
{{/* Gather partials for this context */}}
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ $meta.Add "partials" (slice (partial "meta/date.html" .Date)) }}
{{ end }}
2022-09-10 14:05:37 -05:00
2022-10-01 19:03:22 -05:00
{{ if and (.Params.showDateUpdated | default (.Site.Params.article.showDateUpdated | default false)) (ne (partial
"functions/date.html" .Date) (partial "functions/date.html" .Lastmod)) }}
{{ $meta.Add "partials" (slice (partial "meta/date-updated.html" .Lastmod)) }}
{{ end }}
2022-09-10 14:05:37 -05:00
2022-10-01 19:03:22 -05:00
{{ if and (.Params.showWordCount | default (.Site.Params.article.showWordCount | default false)) (ne .WordCount 0) }}
{{ $meta.Add "partials" (slice (partial "meta/word-count.html" .)) }}
{{ end }}
2022-09-10 14:05:37 -05:00
2022-10-01 19:03:22 -05:00
{{ if and (.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true)) (ne .ReadingTime 0)
}}
{{ $meta.Add "partials" (slice (partial "meta/reading-time.html" .)) }}
{{ end }}
2022-09-10 14:05:37 -05:00
2022-10-01 19:03:22 -05:00
{{ if (.Params.showViews | default (.Site.Params.article.showViews | default false)) }}
{{ $meta.Add "partials" (slice (partial "meta/views.html" .)) }}
{{ end }}
2022-10-01 19:03:22 -05:00
{{ if (.Params.showLikes | default (.Site.Params.article.showLikes | default false)) }}
{{ $meta.Add "partials" (slice (partial "meta/likes.html" .)) }}
{{ end }}
{{ if and (eq $scope "single") (.Params.showLikes | default (.Site.Params.article.showLikes | default false)) }}
{{ $meta.Add "partials" (slice (partial "meta/likes_button.html" .)) }}
{{ end }}
{{ if and (eq $scope "single") (.Params.showEdit | default (.Site.Params.article.showEdit | default false)) }}
{{ $meta.Add "partials" (slice (partial "meta/edit.html" .)) }}
{{ end }}
2022-09-28 17:43:50 -05:00
2022-10-01 19:03:22 -05:00
<div class="flex flex-row flex-wrap items-center">
{{/* Output partials */}}
{{ with ($meta.Get "partials") }}
{{ delimit . "<span class=\"px-2 text-primary-500\">&middot;</span>" }}
2022-09-28 17:43:50 -05:00
{{ end }}
2022-10-01 19:03:22 -05:00
{{/* Output draft label */}}
{{ if and (eq $scope "single") (and .Draft .Site.Params.article.showDraftLabel) }}
<span class="pl-2">{{ partial "badge.html" (i18n "article.draft" | emojify) }}</span>
2022-09-10 14:05:37 -05:00
{{ end }}
2022-10-01 19:03:22 -05:00
</div>
2022-10-29 10:53:27 -05:00
{{ if .Params.showAuthorsBadges | default (.Site.Params.article.showAuthorsBadges | default false) }}
2022-10-01 19:03:22 -05:00
<div class="flex flex-row flex-wrap items-center">
2022-10-13 17:29:04 -05:00
{{ range $taxonomy, $terms := .Site.Taxonomies }}
2022-10-29 10:53:27 -05:00
{{ if (eq $taxonomy "authors")}}
2022-10-13 17:29:04 -05:00
{{ if (gt (len ($context.GetTerms $taxonomy)) 0) }}
2022-10-29 10:53:27 -05:00
{{ range $i, $a := $context.GetTerms $taxonomy }}
{{ if not (eq $i 0) }} ,&nbsp; {{ end }} <div style="cursor: pointer;" onclick="window.open({{ $a.RelPermalink }})">{{ $a.LinkTitle }}</div>
2022-10-13 17:29:04 -05:00
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</div>
{{ end }}
2022-10-29 10:53:27 -05:00
{{/* Output taxonomies */}}
{{ if .Params.showTaxonomies | default (.Site.Params.article.showTaxonomies | default false) }}
2022-10-13 17:29:04 -05:00
<div class="flex flex-row flex-wrap items-center">
2022-10-01 19:03:22 -05:00
{{ range $taxonomy, $terms := .Site.Taxonomies }}
2022-10-29 10:53:27 -05:00
{{ if and (not (eq $taxonomy "authors")) (not (eq $taxonomy "series"))}}
2022-10-01 19:03:22 -05:00
{{ if (gt (len ($context.GetTerms $taxonomy)) 0) }}
{{ range $context.GetTerms $taxonomy }}
<span style="margin-top:0.5rem" class="mr-2" onclick="window.open({{ .RelPermalink }});">
{{ partial "badge.html" .LinkTitle }}
</span>
{{ end }}
{{ end }}
{{ end }}
2022-10-13 17:29:04 -05:00
{{ end }}
2022-10-01 19:03:22 -05:00
</div>
2022-10-01 19:22:43 -05:00
{{ end }}
2022-10-01 19:03:22 -05:00
{{ end }}