about summary refs log tree commit diff
path: root/layouts/_default/single.html
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-04-06 12:32:43 -0700
committerFranck Cuny <franck@fcuny.net>2021-04-06 12:32:43 -0700
commitbaaf4ee9756d29f6ca9dab8386abc8f54a8fb05f (patch)
treefca548dadaeb3970bc4580cbaa74b3c7d51961be /layouts/_default/single.html
parentcss: update style for links and headers (diff)
downloadfcuny.net-baaf4ee9756d29f6ca9dab8386abc8f54a8fb05f.tar.gz
layout: add date and tags to single pages
We want to show the tags and the published/updated date for the
articles.

Add to the CSS the classes for these new elements.
Diffstat (limited to 'layouts/_default/single.html')
-rw-r--r--layouts/_default/single.html27
1 files changed, 26 insertions, 1 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index a8c1dc7..0ab5e35 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -4,7 +4,32 @@
 
 <h1>{{ .Title }}</h1>
 
-<p><span class="published">{{ .Date.Format "January 2021" }}</span></p>
+<div class="meta">
+  {{- $pub := .Date.Format "2006-01-02" -}}
+  {{- $mod := "" -}}
+  {{- if (not .GitInfo) }}
+  {{- $mod = .Lastmod.Format "2006-01-02" -}}
+  {{ else }}
+  {{- $mod = .Page.GitInfo.CommitDate.Format "2006-01-02" -}}
+  {{ end -}}
+  {{ if eq $pub $mod }}
+  <div class="meta_date">published {{ $pub }}</div>
+  {{ else }}
+  <div class="meta_date">published {{ $pub }}, last modified {{ $mod }}</div>
+  {{ end }}
+  {{ if .Params.tags }}
+  <div>
+  {{ if eq (len .Params.tags) 1 }}
+  in tag
+  {{ else }}
+  in tags
+  {{ end }}
+  {{ range $idx, $tag := .Params.tags }}
+  <span class="meta_tags"><a href="/tags/{{ $tag | urlize }}/">{{ $tag }}</a></span>
+  {{ end }}
+  </div>
+  {{ end }}
+</div>
 
 {{ .Content }}