commit fa328018d73cd7935bf917c7a7d270d4ec124c74
parent fc2223db76d5408b12ee458ddac28ac7a3f10e68
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date: Thu, 28 Jun 2018 09:57:18 -0500
Create a partial for parsing iso formatted dates.
Diffstat:
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/layouts/_default/home.html b/layouts/_default/home.html
@@ -9,7 +9,7 @@
<ul>
{{ range (first 5 (where .Data.Pages "Section" "!=" "") ) }}
- <li><span class="date">{{ .Date.Format "2006-01-02" }}</span> <a href="{{ .URL }}">{{ .Title }}</a></li>
+<li>{{ partial "iso_date.html" .Date }} <a href="{{ .URL }}">{{.Title}}</a></li>
{{ end }}
</ul>
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
@@ -6,7 +6,7 @@
<ul>
{{ range (where .Data.Pages "Section" "!=" "") }}
- <li><span class="date">{{ .Date.Format "2006-01-02" }}</span> <a href="{{ .URL }}">{{ .Title }}</a></li>
+ <li>{{ partial "iso_date.html" .Date }} <a href="{{ .URL }}">{{ .Title }}</a></li>
{{ end }}
</ul>
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
@@ -2,7 +2,7 @@
<article>
<header class="article-meta">
<h1 class="title">{{ .Title }}</h1>
- {{ if (lt 0 .Date) }}<time datetime={{ .Date.Format "2006-01-02T15:04:05-07:00" }}>{{ .Date.Format "2006-01-02" }}</time>{{ end }}
+ {{ if (lt 0 .Date) }}{{ partial "iso_date.html" .Date }}{{ end }}
<p class="terms">
{{ range $key, $_ := .Site.Taxonomies }}
{{ with ($.Param $key) }}
diff --git a/layouts/partials/iso_date.html b/layouts/partials/iso_date.html
@@ -0,0 +1 @@
+<time datetime={{ .Format "2006-01-02T15:04:05-07:00" }}>{{ .Format "2006-01-02" }}</time>