Skip to content

Commit

Permalink
🐛 Fix: use dateFormat function to render localized dates
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Ginobili <[email protected]>
Co-authored-by: Cell <[email protected]>
  • Loading branch information
stefanoginobili and Lruihao committed Sep 3, 2023
1 parent 3443e07 commit 78416fa
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 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
4 changes: 2 additions & 2 deletions layouts/taxonomy/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ <h3 class="group-title">{{ .Key }}</h3>
{{- range .Pages -}}
<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.list.dateFormat | default "01-02" | .Date.Format -}}
<span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Date.Format }}'>
{{- .Date | dateFormat ($.Site.Params.list.dateFormat | default "01-02") -}}

This comment has been minimized.

Copy link
@Lruihao

Lruihao Sep 3, 2023

Author Member

I added the missing fixes in this file. Thanks @stefanoginobili

</span>
</article>
{{- end -}}
Expand Down

1 comment on commit 78416fa

@vercel
Copy link

@vercel vercel bot commented on 78416fa Sep 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

fixit – ./

fixit-git-master-cell-x.vercel.app
fixit-cell-x.vercel.app
hugofixit.vercel.app
fixit.lruihao.cn

Please sign in to comment.