congo/layouts/partials/article-meta.html

48 lines
1.8 KiB
HTML
Raw Normal View History

2021-08-21 01:42:40 +00: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 . ) }}
{{ $context = .context }}
{{ $scope = cond (not .scope) nil .scope }}
{{ end }}
2021-08-21 01:42:40 +00:00
{{ with $context }}
{{ $meta := newScratch }}
{{/* Gather partials for this context */}}
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
2022-01-23 19:28:50 +00:00
{{ $meta.Add "partials" (slice (partial "meta/date.html" .Date)) }}
{{ end }}
{{ if .Params.showDateUpdated | default (.Site.Params.article.showDateUpdated | default false) }}
{{ $meta.Add "partials" (slice (partial "meta/date-updated.html" .Lastmod)) }}
2021-08-21 01:42:40 +00:00
{{ end }}
{{ if and (.Params.showWordCount | default (.Site.Params.article.showWordCount | default false)) (ne .WordCount 0) }}
2021-12-16 09:37:46 +00:00
{{ $meta.Add "partials" (slice (partial "meta/word-count.html" .)) }}
{{ end }}
2021-08-21 01:42:40 +00: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 }}
{{ if and (eq $scope "single") (.Params.showEdit | default (.Site.Params.article.showEdit | default false)) }}
{{ $meta.Add "partials" (slice (partial "meta/edit.html" .)) }}
{{ end }}
<div class="flex flex-row flex-wrap items-center">
2021-08-21 01:42:40 +00:00
{{/* Output partials */}}
{{ with ($meta.Get "partials") }}
{{ delimit . "<span class=\"px-2 text-primary-500\">&middot;</span>" }}
{{ end }}
{{/* 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>
{{ end }}
</div>
{{ end }}