Use locale-aware alias for date formatting (#115)

":date_medium" matches "Jan 2, 2006" in english locales while adapting
to hugo's configured locale.
This commit is contained in:
Patrick Georgi 2024-08-05 20:10:42 +02:00 committed by GitHub
parent e16b28fa10
commit d8819d5eee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4 additions and 4 deletions

View file

@ -9,7 +9,7 @@
{{- range .Data.Pages -}}
{{- if (not (in (.Site.Params.excludedTypes | default (slice "page")) .Type)) -}}
<li class="post">
<a href="{{ .RelPermalink }}">{{.Title}}</a> <span class="meta">{{ dateFormat "Jan 2, 2006" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</span>
<a href="{{ .RelPermalink }}">{{.Title}}</a> <span class="meta">{{ dateFormat ":date_medium" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</span>
</li>
{{- end -}}
{{- end -}}

View file

@ -3,7 +3,7 @@
<article>
<div class="title">
<h1 class="title">{{ .Title }}</h1>
<div class="meta">Posted on {{ dateFormat "Jan 2, 2006" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</div>
<div class="meta">Posted on {{ dateFormat ":date_medium" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</div>
</div>
{{ if isset .Params "tldr" }}
<div class="tldr">

View file

@ -9,7 +9,7 @@
{{- range .Data.Pages -}}
{{- if (not (in (.Site.Params.excludedTypes | default (slice "page")) .Type)) -}}
<li class="post">
<a href="{{ .RelPermalink }}">{{.Title}}</a> <span class="meta">{{ dateFormat "Jan 2, 2006" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</span>
<a href="{{ .RelPermalink }}">{{.Title}}</a> <span class="meta">{{ dateFormat ":date_medium" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</span>
</li>
{{- end -}}
{{- end -}}

View file

@ -16,7 +16,7 @@
{{ range $paginator.Pages }}
<section class="list-item">
<h1 class="title"><a href="{{ .RelPermalink }}">{{.Title}}</a></h1>
<time>{{ dateFormat "Jan 2, 2006" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</time>
<time>{{ dateFormat ":date_medium" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</time>
<br>{{ template "partials/pagedescription.html" . }}
<a class="readmore" href="{{ .RelPermalink }}">Read more ⟶</a>
</section>