1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-11-24 21:20:17 +01:00

layouts: Don't assume date_format is defined

User can override the date format with date_format, but we should
have a default in the case that the user hasn't defined it.
This commit is contained in:
Alan Orth 2016-10-17 23:39:41 -04:00
parent fdc982b9fb
commit cdcae6c8a4
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 6 additions and 2 deletions

View File

@ -1,9 +1,11 @@
{{ define "title" }}{{ .Title | markdownify }} | {{ .Site.Title }}{{ end }}
{{ define "main" }}
{{ $dateFormat := default "Mon Jan 2, 2006" (index .Site.Params "date_format") }}
<article class="blog-post">
<header>
<h2 class="blog-post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2>
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format .Site.Params.date_format }}</time> by {{ .Params.author | default .Site.Params.author }}{{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format $dateFormat }}</time> by {{ .Params.author | default .Site.Params.author }}{{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
</header>
{{ .Content }}

View File

@ -1,7 +1,9 @@
{{ $dateFormat := default "Mon Jan 2, 2006" (index .Site.Params "date_format") }}
<article class="blog-post">
<header>
<h2 class="blog-post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2>
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format .Site.Params.date_format }}</time> by {{ .Params.author | default .Site.Params.author }}{{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format $dateFormat }}</time> by {{ .Params.author | default .Site.Params.author }}{{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
</header>
{{ .Summary }}
<a href='{{ .Permalink }}'>{{ i18n "readMore" }} →</a>