Commit e1fe7c6a authored by Kaushal Modi's avatar Kaushal Modi

Don't show 0001-Jan-01 dates

parent 77f504f2
......@@ -11,9 +11,7 @@
<h2><a href='{{ .Permalink }}'> {{ .Title }}</a> </h2>
</span>
<span class="left post-date">
{{ partial "publishdate-maybe.html" . }}
</span>
<div class="left">{{ partial "date-maybe.html" . }}</div>
<div class="clear-float"></div>
<!-- <br /> -->
......
......@@ -2,7 +2,7 @@
<div class="post">
<h1 class="post-title">{{ .Title }}</h1>
<span class="post-date">{{ partial "publishdate-maybe.html" . }}</span>
{{ partial "date-maybe.html" . }}
{{ if not .Params.notoc }}
{{ with .TableOfContents }}
......
......@@ -13,7 +13,7 @@
<article class="summary">
<header>
<h2 class="post-title"><a href='{{ .Permalink }}'> {{ .Title }}</a> </h2>
<div class="post-date">{{ partial "publishdate-maybe.html" . }} - {{ .FuzzyWordCount }} Words</div>
{{ partial "date-maybe.html" . }}
</header>
<div class="post" >
......
{{ with .Date }}
{{ if (not (eq (dateFormat "2006-01-02" .) "0001-01-01")) }}
<span class="post-date">{{ dateFormat $.Site.Params.dateform . | safeHTML }}</span>
{{ end }}
{{ end }}
{{ dateFormat .Site.Params.dateform (default .Date (.PublishDate)) }}
<!-- Above is the optimized version of below, thanks to https://discuss.gohugo.io/t/how-to-use-the-publishdate-if-both-publishdate-and-date-are-set-in-frontmatter/5142/3?u=kaushalmodi -->
{{/* with .PublishDate */}}
{{/* if eq ($.PublishDate.Format "2006-01-02") "0001-01-01" */}}
<!-- Print the Date instead of PublishDate if PublishDate is defined but at its initial value of Jan 1, 0001 -->
{{/* $.Date.Format $.Site.Params.dateform */}}
{{/* else */}}
{{/* $.PublishDate.Format $.Site.Params.dateform */}}
{{/* end */}}
{{/* end */}}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment