Change '.Date' to '.PublishDate'

It's better for three reasons:

* It is a predefined frontmatter variable from Hugo.
* When unset, it is basically the '.Date'.
* More specific and the 'date' variable can now be assigned for the
creation date.
This commit is contained in:
Gabriel Arazas 2020-11-06 02:25:43 +08:00
parent 8f7fa69761
commit 86346b1af1
5 changed files with 25 additions and 9 deletions

View File

@ -19,6 +19,9 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
* The post metadata styling. * The post metadata styling.
* All references of `.Date` into `.PublishDate` as it is more reliable.
It is also one of the https://gohugo.io/content-management/front-matter#predefined[predefined front matter variable] which can be defined with the `publishdate` variable.
=== Fixed === Fixed

View File

@ -41,13 +41,25 @@ As previously mentioned, this theme is made to be easily extensible.
With some integration with the huge ecosystem of Hugo, you can make the theme feature the following highlights. With some integration with the huge ecosystem of Hugo, you can make the theme feature the following highlights.
* Deploy with web feeds with [a Hugo module I made that adds them](https://github.com/foo-dogsquared/hugo-web-feeds). * Deploy with web feeds with [a Hugo module I made that adds them](https://github.com/foo-dogsquared/hugo-web-feeds).
* Make more modern with [a theme extension](https://github.com/foo-dogsquared/hugo-mod-more-contentful). * Use the whole icon set from [Simple Icons](https://simpleicons.org/) with a [Hugo module](https://github.com/foo-dogsquared/hugo-mod-simple-icons).
* Make more it modern with [an extended version of this theme](https://github.com/foo-dogsquared/hugo-theme-more-contentful).
More possibilities are there if you tinker it with your own modifications. More possibilities are there if you tinker it with your own modifications.
## Project goals
* A clean reader interface for your content that is easy to modify to your liking.
* Make it easy for the user to seamlessly migrate or switch between themes.
- Which means, no custom shortcodes, archetypes, or (lots of) frontmatter variables.
* Focus on making it accessible to visually-impaired users.
* A low web budget of less 30KB that can load under 1 second (with the default configuration, anyways).
## Installation ## Installation
I assume you already have [Git](https://git-scm.com/) and [Hugo](https://gohugo.io/) installed. I assume you already have [Git](https://git-scm.com/) and [Hugo](https://gohugo.io/) installed.
@ -60,7 +72,8 @@ You can install the Hugo theme in two ways.
### Using Hugo module ### Using Hugo module
You can quickly add this theme as a [Hugo module](https://gohugo.io/hugo-modules/). You can quickly add this theme as a [Hugo module](https://gohugo.io/hugo-modules/).
It does have a prerequisite of using Hugo v0.56.0 and above as well as a [Go runtime](https://golang.org/). Hugo modules are only available in Hugo v0.56.0.
It also requires a Go runtime and Git installed.
To get started, initialize your Hugo project as a Hugo module. To get started, initialize your Hugo project as a Hugo module.

View File

@ -13,11 +13,11 @@ Otherwise, we take the pages of a section. */ -}}
<article class="post"> <article class="post">
<h1><a href="{{ .Permalink }}" aria-label="{{ .Title }}">{{ .Title }}</a></h1> <h1><a href="{{ .Permalink }}" aria-label="{{ .Title }}">{{ .Title }}</a></h1>
<div class="post__meta"> <div class="post__meta">
<time datetime="{{ .Date }}"> <time datetime="{{ .PublishDate }}">
{{ .Date.Format "2006-01-02" }} {{ .PublishDate.Format "2006-01-02" }}
</time> </time>
{{- 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 }}">{{ .Lastmod.Format "2006-01-02" }}</time> <time datetime="{{ .Lastmod }}">{{ .Lastmod.Format "2006-01-02" }}</time>
{{- end }} {{- end }}

View File

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

View File

@ -13,7 +13,7 @@
<ul class="taxonomy__pages"> <ul class="taxonomy__pages">
{{- range $pages }} {{- range $pages }}
<li class="taxonomy__page"> <li class="taxonomy__page">
<date datetime="{{ .Date }}">{{ .Date.Format "2006-01-02" }}</date> <date datetime="{{ .PublishDate }}">{{ .PublishDate.Format "2006-01-02" }}</date>
<a href="{{ .Permalink }}">{{ .LinkTitle }}</a> <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
</li> </li>
{{- end }} {{- end }}