Skip to content

Commit

Permalink
fix: datetime format
Browse files Browse the repository at this point in the history
  • Loading branch information
mnjm committed Jul 29, 2024
1 parent adddf61 commit d949a00
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
1 change: 1 addition & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ blockquote {
padding-left: 2rem;
background: var(--secondary-color-dark);
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
border-radius: 0 var(--radius) var(--radius) 0;
}

details {
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/list/page-link.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{ .LinkTitle | emojify }} </a> </div>
{{ if $showDate }}
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateHuman := dateFormat "Jan 01, 2006" .Date }}
{{ $dateHuman := dateFormat "Jan 02, 2006" .Date }}
<time datetime="{{ $dateMachine }}"> {{ $dateHuman }} </time>
{{ end }}
</li>
Expand Down
48 changes: 18 additions & 30 deletions layouts/partials/single/meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,29 @@
{{ $showModDate := .Params.showModDate | default (.Site.Params.article.showModDate | default false) }}
{{ $showReadingTime := .Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true) }}

{{ $meta := slice }}
{{ $icons := slice }}
<p>
{{/* Date Reading time and Draft label */}}
{{ if $showDate }}
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateHuman := .Date | time.Format "Jan 01, 2006" }}
{{ $icons = $icons | append "calender" }}
{{ $meta = $meta | append (printf "Posted on <time datetime=\"%s\">%s</time>" $dateMachine $dateHuman) }}

{{ $dateModMachine := .Lastmod | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateModHuman := .Lastmod | time.Format "Jan 01, 2006" }}
{{ if and $showModDate (ne $dateModHuman $dateHuman) }}
{{ $icons = $icons | append "pencil" }}
{{ $meta = $meta | append (printf "Last edited <time datetime=\"%s\">%s</time>" $dateModMachine $dateModHuman) }}
{{ end }}
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateHuman := .Date | time.Format "Jan 2, 2006" }}
<span class="meta-icon">{{ partial "icon.html" "calender" }}</span>
Posted on <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
{{ $dateModMachine := .Lastmod | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateModHuman := .Lastmod | time.Format "Jan 2, 2006" }}
{{ if and $showModDate (ne $dateModHuman $dateHuman) }}
<span class="meta-icon">{{ partial "icon.html" "pencil" }}</span>
Last edited <time datetime="{{ $dateModMachine }}">{{ $dateModHuman }}</time>
{{ end }}
{{ end }}
{{ if $showReadingTime }}
{{ $icons = $icons | append "time" }}
{{ if gt .ReadingTime 1 }}
{{ $meta = $meta | append (printf "%s mins" (.ReadingTime | markdownify)) }}
{{ else }}
{{ $meta = $meta | append (printf "%s min" (.ReadingTime | markdownify)) }}
{{ end }}
<span class="meta-icon">{{ partial "icon.html" "time" }}</span>
{{ if gt .ReadingTime 1 }}
{{ printf "%s mins" (.ReadingTime | markdownify) }}
{{ else }}
{{ printf "%s min" (.ReadingTime | markdownify) }}
{{ end }}
{{ end}}
{{ if .Draft }}
{{ $icons = $icons | append "edit" }}
{{ $meta = $meta | append "<span class=\"draft-lbl\">DRAFT</span>" }}
<span class="draft-lbl"><span class="meta-icon">{{ partial "icon.html" "edit" }}</span>DRAFT</span>
{{ end }}
{{/* $meta := delimit $meta " | " */}}
{{ if gt (len $meta) 0 }}
<p>
{{ range $idx, $ent := $meta }}
{{ if gt $idx 0 }} &middot; {{ end }}
{{ $iname := index $icons $idx }}
<span class="meta-icon"> {{ partial "icon.html" $iname }} </span> {{ $ent | safeHTML }}
{{ end }}
</p>
{{ end }}

0 comments on commit d949a00

Please sign in to comment.