summaryrefslogtreecommitdiff
path: root/layouts/_default/single.html
blob: e23acad08ecb681e21a4294bc09ec5cfa5849baa (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
{{ define "main" }}
    {{ if eq .Type "posts" }}
        {{ partial "components/post-page-header.html" . }}
    {{ else }}
        {{ partial "header.html" . }}
    {{ end }}
    <article
        class="post {{ .Site.Language.LanguageName }}"
        id="article"
    >
      <!-- Post Header -->
      <header
        style="view-transition-name: post-{{ .File.UniqueID }}"
        class="post-header"
      >
        {{ if in .Site.Params.mainSections .Type }}
        {{ 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 }}
            <time class="post-date" datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}">
              {{ .Date.Format "2006-1-2" }}
            </time>
            {{ end }}
            <span>·</span>
            {{ 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>
        {{ end }}
      </header>

      <!-- Post Content -->
      <div id="post-content" class="post-content markdown-body"
          style="view-transition-name: post-content-{{ .File.UniqueID }}">
        {{ if .Params.toc }}
        <div id="toc-container"><div id="toc"></div></div>
        {{ end }}
        {{ .Site.Params.postHeaderContent | safeHTML }}
        {{ .Content }}
        {{ if and (eq .Site.Language.Lang "zh") (eq .Section "posts") }}
            <p style="font-size: 0.9rem">如果你觉得文章对你有帮助,可以考虑<a href="/sponsor">赞助作者</a></p>
        {{ end }}
      </div>

      {{ if in .Site.Params.mainSections .Type }}
        {{ partial "components/comment.html" . }}
      {{ end }}

      <script src="/js/tocbot.min.js"></script>
      <script>
      tocbot.init({
        tocSelector: '#toc',
        contentSelector: '#post-content',
        headingSelector: 'h2, h3:not(blockquote > h3)',
        hasInnerContainers: true,
        scrollSmoothOffset: -30
      });
      </script>

    </article>
{{ end }}