summaryrefslogtreecommitdiff
path: root/layouts/_partials/components/date.html
blob: 1998202f3633de24f951136c5299b309bef34cbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{{ if .Date }}
    {{ $hour := .Date.Hour }}
    {{ $fuzzyTimes := slice
        (dict "limit" 5  "label" "凌晨")
        (dict "limit" 7  "label" "清晨")
        (dict "limit" 11 "label" "早上")
        (dict "limit" 13 "label" "中午")
        (dict "limit" 17 "label" "下午")
        (dict "limit" 19 "label" "傍晚")
        (dict "limit" 22 "label" "晚上")
    }}
    {{ $fuzzyTime := "深夜" }} {{/* default */}}
    {{ range $fuzzyTimes }}
    {{ if lt $hour .limit }}
        {{ $fuzzyTime = .label }}
        {{ break }}
    {{ end }}
    {{ end }}

  <time class="post-date"
        datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}"
        data-pagefind-sort="date[datetime], weight[data-weight]"
        data-weight="{{ if .Params.featured }}30{{ else }}20{{ end }}">
    {{ .Date.Format "2006年1月2日" }} {{ $fuzzyTime }}
  </time>
{{ end }}