Skip to content

Commit

Permalink
Use dateFormat function to render localized dates
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoginobili committed Sep 2, 2023
1 parent ff95cfa commit 4c6f643
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion layouts/_default/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2 class="group-title">{{ .Key }}</h2>
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">{{- .Title -}}</a>
<span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Date.Format }}'>
{{- $.Site.Params.section.dateFormat | default "01-02" | .Date.Format -}}
{{- .Date | dateFormat ($.Site.Params.section.dateFormat | default "01-02") -}}
</span>
</article>
{{- end -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1 class="single-title" itemprop="name headline">
<div class="post-meta">
{{- partial "single/post-author.html" . -}}

{{- with .Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format -}}
{{- with .PublishDate | dateFormat (.Site.Params.dateFormat | default "2006-01-02") -}}
&nbsp;<span class="post-publish" title='{{ "2006-01-02 15:04:05" | $.PublishDate.Format }}'>
{{- printf `<time datetime="%v">%v</time>` . . | dict "Date" | T "single.publishedOnDate" | safeHTML -}}
</span>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/recently-updated.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2 class="group-title">{{- T "section.recentlyUpdated" -}}</h2>
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">{{- .Title -}}</a>
<span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Lastmod.Format }}'>
{{- with .Site.Params.section.dateformat | default "01-02" | .Lastmod.Format -}}
{{- with .Lastmod | dateFormat (.Site.Params.section.dateformat | default "01-02") -}}
{{- dict "Date" . | T "single.updatedOnDate" -}}
{{- end -}}
</span>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/single/expiration-reminder.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
<div class="details-content">
<div class="admonition-content">
{{- with .Site.Params.dateformat | default "2006-01-02" | $updateTime.Format -}}
{{- with $updateTime | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
{{- dict "Date" . | T "single.expirationReminder" -}}
{{- end -}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/single/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="post-info-line">
<div class="post-info-mod">
<span title="{{ dict "Date" ("2006-01-02 15:04:05" | .Lastmod.Format) | T "single.updatedOnDate" }}">
{{- with .Site.Params.dateformat | default "2006-01-02" | .Lastmod.Format -}}
{{- with .Lastmod | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
{{- dict "Date" . | T "single.updatedOnDate" -}}&nbsp;
{{- if $gitRepo -}}
{{- with $.GitInfo -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ <h1 class="single-title animate__animated animate__flipInX">
{{- end -}}
</div>
<div class="post-meta-line">
{{- with .Site.Params.dateformat | default "2006-01-02" | .PublishDate.Format -}}
{{- with .PublishDate | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
<span title="{{ dict "Date" ("2006-01-02 15:04:05" | $.PublishDate.Format) | T "single.publishedOnDate" }}">
{{- dict "Class" "fa-regular fa-calendar-alt fa-fw me-1" | partial "plugin/icon.html" -}}
{{- printf `<time datetime="%v">%v</time>` . . | safeHTML -}}
</span>&nbsp;
{{- end -}}
{{- with .Site.Params.dateformat | default "2006-01-02" | .Lastmod.Format -}}
{{- with .Lastmod | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
<span title="{{ dict "Date" ("2006-01-02 15:04:05" | $.Lastmod.Format) | T "single.updatedOnDate" }}">
{{- dict "Class" "fa-regular fa-edit fa-fw me-1" | partial "plugin/icon.html" -}}
{{- printf `<time datetime="%v">%v</time>` . . | safeHTML -}}
Expand Down

0 comments on commit 4c6f643

Please sign in to comment.