Skip to content

Commit

Permalink
feat: add the created_at parameter, when false hide the date of creat…
Browse files Browse the repository at this point in the history
…ed at (#19)
  • Loading branch information
razonyang committed Dec 14, 2023
1 parent b53d89d commit 91e45ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ path = "github.com/hugomods/icons/vendors/bootstrap"
date_format = ":date_full"
icons = true
font_size = ".825rem"
created_at = true
25 changes: 15 additions & 10 deletions layouts/partials/hb/modules/revision/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- $createdAt := default true site.Params.hb.revision.created_at }}
{{- if or $createdAt (ne .Lastmod .Date) }}
<div class="hb-module hb-revision text-body-secondary d-flex flex-wrap">
{{- $params := site.Params.hb.revision }}
{{- $icons := default true $params.icons }}
Expand All @@ -14,14 +16,17 @@
{{- end }}
</span>
{{- end }}
{{- $date := .Date | time.Format $format }}
{{- $dateFull := printf "%s %s" (.Date | time.Format ":date_full") (.Date | time.Format ":time_full") }}
<span class="hb-revision-date" title="{{ i18n `created_at` (dict `Date` $dateFull) }}">
{{- if $icons }}
{{ partial "icons/icon" (dict "vendor" "bs" "name" "calendar-plus") }}
<span>{{ $date }}</span>
{{- else }}
{{ i18n `created_at` (dict `Date` $date) }}
{{- end }}
</span>
{{- if $createdAt }}
{{- $date := .Date | time.Format $format }}
{{- $dateFull := printf "%s %s" (.Date | time.Format ":date_full") (.Date | time.Format ":time_full") }}
<span class="hb-revision-date" title="{{ i18n `created_at` (dict `Date` $dateFull) }}">
{{- if $icons }}
{{ partial "icons/icon" (dict "vendor" "bs" "name" "calendar-plus") }}
<span>{{ $date }}</span>
{{- else }}
{{ i18n `created_at` (dict `Date` $date) }}
{{- end }}
</span>
{{- end }}
</div>
{{- end }}

0 comments on commit 91e45ae

Please sign in to comment.