layouts: Add DateFormat parameter (#39)

* User can change Date Format to be displayed in Front Matter
* Formats supported by Hugo can be found here: https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference
This commit is contained in:
Northerner-coder 2020-10-16 12:42:32 -04:00 committed by GitHub
parent a980d10bfc
commit db52aa9942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -22,7 +22,7 @@
{{- .Title | markdownify }} {{- .Title | markdownify }}
</h3> </h3>
<div class="archive-meta"> <div class="archive-meta">
<time>{{ .Date.Format "January 2, 2006" }}</time> <time>{{ .Date.Format (default "January 2, 2006" .Site.Params.DateFormat) }}</time>
{{- if $.Site.Params.ShowReadingTime }}&nbsp;·&nbsp; {{- if $.Site.Params.ShowReadingTime }}&nbsp;·&nbsp;
{{- $default_txt := print .ReadingTime " " "min" }} {{- $default_txt := print .ReadingTime " " "min" }}
{{- i18n "read_time" .ReadingTime | default $default_txt }}{{ end }} {{- i18n "read_time" .ReadingTime | default $default_txt }}{{ end }}

View File

@ -52,7 +52,7 @@
</section> </section>
{{- end }} {{- end }}
<footer class="entry-footer"> <footer class="entry-footer">
<time>{{ .Date.Format "January 2, 2006" }}</time> <time>{{ .Date.Format (default "January 2, 2006" .Site.Params.DateFormat) }}</time>
{{- if $.Site.Params.ShowReadingTime }}&nbsp;·&nbsp; {{- if $.Site.Params.ShowReadingTime }}&nbsp;·&nbsp;
{{- $default_txt := print .ReadingTime " " "min" }} {{- $default_txt := print .ReadingTime " " "min" }}
{{- i18n "read_time" .ReadingTime | default $default_txt }}{{ end }} {{- i18n "read_time" .ReadingTime | default $default_txt }}{{ end }}

View File

@ -8,7 +8,7 @@
</h1> </h1>
{{- if .Params.hideMeta }}{{ else }} {{- if .Params.hideMeta }}{{ else }}
<div class="post-meta"> <div class="post-meta">
<time>{{ .Date.Format "January 2, 2006" }}</time> <time>{{ .Date.Format (default "January 2, 2006" .Site.Params.DateFormat) }}</time>
{{- if $.Site.Params.ShowReadingTime -}}&nbsp;·&nbsp; {{- if $.Site.Params.ShowReadingTime -}}&nbsp;·&nbsp;
{{- $default_txt := print .ReadingTime " " "min" }} {{- $default_txt := print .ReadingTime " " "min" }}
{{- i18n "read_time" .ReadingTime | default $default_txt }}{{ end }} {{- i18n "read_time" .ReadingTime | default $default_txt }}{{ end }}