virtuallypotato/layouts/partials/post-meta.html

42 lines
1.6 KiB
HTML
Raw Normal View History

{{- $showShare := ne (.Param "showshare") false }}
{{- $showDate := ne (.Param "showdate") false }}
{{- $postDate := .Date.Format (default "Jan 2, 2006" $.Site.Params.dateFormat) }}
{{- $updateDate := .Lastmod.Format (default "Jan 2, 2006" $.Site.Params.dateFormat) }}
{{- $showReadTime := ne (.Param "showreadtime") false }}
{{- $showPostMeta := or ($showShare) ($showDate) ($showReadTime) (isset .Params "tags") }}
{{- $scratch := newScratch }}
{{- $scratch.Set "writeSeparator" false }}
{{- if $showPostMeta }}
<div class="post_meta">
{{- end }}
{{- if $showDate }}
<span>{{ partial "sprite" (dict "icon" "calendar") }}</span>
<span class="post_date">
{{ $postDate -}}{{- if ne $postDate $updateDate }} ({{ T "updated" }}: {{ $updateDate -}}){{- end }}
</span>
{{- $scratch.Set "writeSeparator" true }}
{{- end }}
{{- if $showReadTime }}
<span class="post_time">{{ if ($scratch.Get "writeSeparator") }} · {{ end }}{{ T "reading_time" . }}</span>
{{- $scratch.Set "writeSeparator" true }}
{{- end }}
{{- with .Params.tags -}}
<span>
{{- if ($scratch.Get "writeSeparator") }}&nbsp;· {{ end }}
{{- range . }}
{{- $tag := urlize . -}}
<a href='{{ absLangURL (printf "tags/%s" $tag) }}' title="{{ . }}" class="post_tag button button_translucent">
{{- . }}
</a>
{{- end }}
</span>
{{- $scratch.Set "writeSeparator" true }}
{{- end }}
{{- if $showShare }}
<span class="page_only">{{ if ($scratch.Get "writeSeparator") }}&nbsp;·{{ end }}{{ partial "share" . }}</span>
{{- $scratch.Set "writeSeparator" true }}
{{- end }}
{{- if $showPostMeta }}
</div>
{{- end }}