feat: provide the facility to customize date format (#10)

This commit is contained in:
Sanjay T. Sharma 2017-09-24 17:56:55 +01:00 committed by olOwOlo
parent 271f73a87f
commit ab7cdc5d3c
5 changed files with 7 additions and 4 deletions

View file

@ -52,6 +52,9 @@ copyright = "" # default: author.name ↓ # 默认为下面配
# paginate of archives, tags and categories # 归档、标签、分类每页显示的文章数目 # paginate of archives, tags and categories # 归档、标签、分类每页显示的文章数目
archive-paginate = 3 archive-paginate = 3
# The date format to use; for a list of valid formats, see https://gohugo.io/functions/format/
dateFormatToUse = "2006-01-02"
# show word count and read time ? # 是否显示字数统计与阅读时间 # show word count and read time ? # 是否显示字数统计与阅读时间
moreMeta = false moreMeta = false

View file

@ -18,7 +18,7 @@
{{ range $paginator.Pages }} {{ range $paginator.Pages }}
<div class="archive-post"> <div class="archive-post">
<span class="archive-post-time"> <span class="archive-post-time">
{{ .Date.Format "2006-01-02" }} {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
</span> </span>
<span class="archive-post-title"> <span class="archive-post-title">
<a href="{{ .URL }}" class="archive-post-link"> <a href="{{ .URL }}" class="archive-post-link">

View file

@ -7,7 +7,7 @@
</p> </p>
<p class="copyright-item"> <p class="copyright-item">
<span class="item-title">{{ $lang.copyright.lastMod }}</span> <span class="item-title">{{ $lang.copyright.lastMod }}</span>
<span class="item-content">{{ .Lastmod.Format "2006-01-02" }}</span> <span class="item-content">{{ .Lastmod.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}</span>
</p> </p>
{{ if $.Site.Params.linkToMarkDown -}} {{ if $.Site.Params.linkToMarkDown -}}
{{ with $.OutputFormats.Get "markdown" -}} {{ with $.OutputFormats.Get "markdown" -}}

View file

@ -6,7 +6,7 @@
<h1 class="post-title">{{ .Title }}</h1> <h1 class="post-title">{{ .Title }}</h1>
<div class="post-meta"> <div class="post-meta">
<span class="post-time"> {{ .Date.Format "2006-01-02" }} </span> <span class="post-time"> {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} </span>
{{ with .Params.categories -}} {{ with .Params.categories -}}
<div class="post-category"> <div class="post-category">
{{ range . -}} {{ range . -}}

View file

@ -3,7 +3,7 @@
<header class="post-header"> <header class="post-header">
<h1 class="post-title"><a class="post-link" href="{{ .URL }}">{{ .Title }}</a></h1> <h1 class="post-title"><a class="post-link" href="{{ .URL }}">{{ .Title }}</a></h1>
<div class="post-meta"> <div class="post-meta">
<span class="post-time"> {{ .Date.Format "2006-01-02" }} </span> <span class="post-time"> {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} </span>
{{ with .Params.categories -}} {{ with .Params.categories -}}
<div class="post-category"> <div class="post-category">
{{ range . -}} {{ range . -}}