Change all '.Date' into '.PublishDate'

This commit is contained in:
Gabriel Arazas 2020-11-06 18:19:33 +08:00
parent 9487442d64
commit 22069d21b6
4 changed files with 13 additions and 7 deletions

View File

@ -19,6 +19,12 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
== [Unreleased]
=== Changed
* All references to `.Date` are changed with `.PublishDate` as it is more reliable.
The `.PublishDate` can be manually set with the `publishdate` frontmatter variable and if unset, it is the assumed to be the `date` variable.
=== Fixed
* Make a few tweaks with CSS.

View File

@ -9,7 +9,7 @@ Otherwise, we take the pages of a section. */ -}}
{{- $pages = where $.Site.RegularPages "Type" "in" $.Site.Params.mainSections }}
{{- end }}
{{- range (where (.Paginate $pages).Pages "Params.hidden" "!=" true) }}
{{- range (.Paginate $pages).Pages }}
<article class="post">
<h1><a href="{{ .Permalink }}" aria-label="{{ .Title }}">{{ .Title }}</a></h1>
{{ partial "partials/components/post-meta.html" . }}

View File

@ -33,11 +33,11 @@
<!-- Only show the creation date if the `date` field is valid. -->
{{- if ne (.PublishDate.Format "2006") "0001" -}}
<!-- Publication date. -->
<p data-content-publication-date="{{ .Date }}">{{ i18n "published_on" }}: <time datetime="{{ .PublishDate.Format "2006-01-02" }}">{{ .PublishDate.Format "2006-01-02" }}</time></p>
<p data-content-publication-date="{{ .PublishDate }}">{{ i18n "published_on" }}: <time datetime="{{ .PublishDate.Format "2006-01-02" }}">{{ .PublishDate.Format "2006-01-02" }}</time></p>
{{- end }}
<!-- Modification date (will only appear if the publication date is less than the modified date.) -->
{{- if ne .Date .Lastmod }}
{{- if ne .PublishDate .Lastmod }}
<p data-content-modification-date="{{ .Lastmod }}">{{ i18n "updated_on" }}: <time datetime="{{ .Lastmod.Format "2006-01-02" }}">{{ .Lastmod.Format "2006-01-02" }}</time></p>
{{- end }}

View File

@ -53,14 +53,14 @@ If the partial is short enough, it should be put here.
{{- define "partials/components/post-meta.html" }}
<div class="list post__meta">
{{- if ne (.Date.Format "2006") "0001" -}}
<time datetime="{{ .Date }}">
{{- if ne (.PublishDate.Format "2006") "0001" -}}
<time datetime="{{ .PublishDate }}">
{{ partial "components/heroicon.html" "calendar" }}
<span style="margin-left: 0.5em;">{{ .Date.Format "2006-01-02" }}</span>
<span style="margin-left: 0.5em;">{{ .PublishDate.Format "2006-01-02" }}</span>
</time>
{{- end }}
{{- if and .GitInfo (ne (.Date.Format "2006-01-02") (.Lastmod.Format "2006-01-02")) }}
{{- if and .GitInfo (ne (.PublishDate.Format "2006-01-02") (.Lastmod.Format "2006-01-02")) }}
<time datetime="{{ .Lastmod }}">
{{ partial "components/heroicon.html" "refresh" }}
<span style="margin-left: 0.5em;">{{ .Lastmod.Format "2006-01-02" }}</span>