summaryrefslogtreecommitdiff
path: root/layouts/posts/single.html
blob: 3fe80a8452fd3cce51d2016b636a914c505b9f79 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{{ define "main" }}
    {{ partial "components/post-page-header.html" . }}
    <article
        class="post {{ .Site.Language.LanguageName }}"
        id="article"
    >
      <!-- Post Header -->
      <header
        style="view-transition-name: post-{{ .File.UniqueID }}"
        class="post-header"
      >
        {{ partial "components/banner.html" . }}
        <!-- Title and Subtitle -->
        <h1 class="post-title">
          {{ .Title }}
          {{ with .Params.subtitle }}
            <small class="post-subtitle">{{ . }}</small>
          {{ end }}
        </h1>
        <!-- Post Meta -->
        <div class="post-meta">
            {{ if .Date }}
              {{ $hour := .Date.Hour }}
              {{ $fuzzyTime := "" }}
              {{ if lt $hour 5 }}
                {{ $fuzzyTime = "凌晨" }}
              {{ else if lt $hour 7 }}
                {{ $fuzzyTime = "清晨" }}
              {{ else if lt $hour 11 }}
                {{ $fuzzyTime = "早上" }}
              {{ else if lt $hour 13 }}
                {{ $fuzzyTime = "中午" }}
              {{ else if lt $hour 17 }}
                {{ $fuzzyTime = "下午" }}
              {{ else if lt $hour 19 }}
                {{ $fuzzyTime = "傍晚" }}
              {{ else if lt $hour 23 }}
                {{ $fuzzyTime = "晚上" }}
              {{ else }}
                {{ $fuzzyTime = "深夜" }}
              {{ end }}

              <time class="post-date" datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}">
                {{ .Date.Format "2006年1月2日" }} {{ $fuzzyTime }}
              </time>
            {{ end }}
            {{ if or .Params.categories .Params.tags }}
            <span>·</span>
            {{ end }}
            {{ if .Params.categories }}
            <a class="post-category" href="/categories/{{ .Params.categories | urlize }}">{{ .Params.categories }}</a>
            {{ end }}
            {{ range .Params.tags }}
            <a class="post-tag" href="{{ site.LanguagePrefix }}/tags/{{ lower . | urlize }}/">#{{ . }}</a>
            {{ end }}
        </div>
      </header>

      <!-- Post Content -->
      <div class="post-content markdown-body"
          style="view-transition-name: post-content-{{ .File.UniqueID }}">
        <!-- TOC -->
        {{ if .Params.toc }}
        {{ partial "components/toc" . }}
        {{ end }}
        <!-- Content -->
        <div id="post-content">{{ .Content }}</div>
        <!-- Endnotes -->
        {{ if .Params.endnotes }}
        <hr>
        <div id="post-endnotes">
            <ul>
              {{ range .Params.endnotes }}
              <li>{{ . | markdownify }}</li>
              {{ end }}
            </ul>
        </div>
        {{ end }}
      </div>

      <!-- Comment -->
      {{ partial "components/comment.html" . }}

      <!-- Now Read This -->
      {{ with site.RegularPages.Related . | first 1 }}
      <div class="nrt post-content">
        <h4 class="nrt-title">{{ T "nowReadThis" }}</h4>
        {{ range . }}
        <div class="nrt-header">
            <a class="nrt-link" href="{{ .RelPermalink }}" data-umami-event="Click Related Post">
                {{ .LinkTitle }}
                {{ with .Params.subtitle }}
                    <span class="nrt-subtitle">:{{ . }}</span>
                {{ end }}
            </a>
            <span class="nrt-reading-time">⏱️ {{ .ReadingTime }}min </span>
        </div>
        <div class="nrt-summary">
            <p>{{ .Summary | plainify }}</p>
        </div>
        {{ end }}
      </div>
      {{ end }}
    </article>
{{ end }}