summaryrefslogtreecommitdiff
path: root/layouts/_default/stats.html
blob: 8ca0cf477ae0ab6afd4236d2adee5adb8ff00970 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{{ define "main" }}
    <style>
    #external-link-rank {
        padding: 0;
        margin: 0;
        max-height: 700px;
        overflow-y: auto;
        box-sizing: border-box;
    }

    .rank-item {
        list-style: none;
        width: 100%;
        margin: 0.5rem 0;
        box-sizing: border-box;
        padding: 0.1rem 0.5rem;
        position: relative;
    }
    .rank-item-text {
        margin-bottom: 0.2rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .rank-item-link {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
    }
    .rank-item-link img {
        width: 1rem;
        height: 1rem;
    }
    .rank-item-count {
        color: var(--secondary-text-color);
    }
    .rank-item-bar {
        background-color: rgba(103,173,91,0.35);
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: -1;
    }

    .site-stats-table {
      width: 100%;
      max-width: 700px;
      border-collapse: collapse;
      margin-bottom: 1.5rem;
    }
    .site-stats-table td {
      padding: 0.5rem;
      text-align: left;
    }
    .site-stats-table td:nth-child(2n) {
      text-align: right;
    }
    .number-pill {
        text-align: center;
        display: inline-block;
        line-height: 1.75rem;
        box-sizing: border-box;
        border-radius: 5px;
        padding: 0 0.5rem;
        background-color: var(--block-background-color);
        font-size: 1rem;
    }
    </style>

    <article>
        {{ partial "header.html" . }}
        {{ partial "components/postnav.html" . }}

        <div class="markdown-content" style="line-height: 2">
            {{ .Content }}
        </div>

        <section>
            <h2>站点统计</h2>
            <table class="site-stats-table">
              <tbody>
                <tr>
                    <td>页面总数</td>
                    <td><span class="number-pill">{{ len .Site.RegularPages }}</span></td>
                    <td>总字数</td>
                    <td>
                        <span class="number-pill">
                        {{- $words := 0 -}}
                        {{- range .Site.RegularPages -}}
                            {{- $words = add $words .WordCount -}}
                        {{- end -}}
                        {{ $words }}
                        </span>
                    </td>
                </tr>
                <tr>
                  <td>标签总数</td>
                  <td><span class="number-pill">{{ len .Site.Taxonomies.tags }}</span></td>
                  <td>专栏数量</td>
                  <td><span class="number-pill">{{ len .Site.Taxonomies.categories }}</span></td>
                </tr>
                <tr>
                  <td>卡片数量</td>
                  <td><span class="number-pill">{{ len (where .Site.RegularPages "Section" "cards") }}</span></td>
                  <td>小说数量</td>
                  <td><span class="number-pill">{{ len (where .Site.RegularPages "Section" "fictions") }}</span></td>
                </tr>
                <tr>
                  <td>书评数量</td>
                  <td><span class="number-pill">{{ len (where .Site.RegularPages "Section" "library") }}</span></td>
                  <td>精选文章数量</td>
                  <td><span class="number-pill">{{ len (where .Site.RegularPages ".Params.featured" true) }}</span></td>
                </tr>
              </tbody>
            </table>
        </section>

        <h2>每月文章字数</h2>
        {{ partial "components/word-count-chart" . }}

        <hr>

        <section>
            <h2>内部链接图谱</h2>
            <p>站内各个页面之间通过超链接建立起来的联系,你可以通过视觉化的双向链接逛逛我的博客。图谱可以缩放和拖拽,你也可以<a href="/graph" style="text-decoration: underline;">点击这里</a>全屏浏览。</p>
            <div class="outbox small">
                <iframe src="https://geedea.pro/graph"
                    style="width:100%;height: 30rem;border-radius:5px;border:none"></iframe>
            </div>
        </section>

        <hr>

        <section>
            <h2>外部链接排行</h2>
            <p>我在页面中嵌入的外部链接主要来自以下域名,引用次数少于 3 的已被排除。</p>

            {{/* Find the maximum link count */}}
            {{ $max := 0 }}
            {{ range .Site.Data.externallinks }}
                {{ if gt (index . 1) $max }}
                    {{ $max = index . 1 }}
                {{ end }}
            {{ end }}

            <ol id="external-link-rank">
            {{ range .Site.Data.externallinks }}
                {{ $label := index . 0 }}
                {{ $count := index . 1 }}
                {{ if gt $count 2 }}
                    {{ $percent := div (mul $count 100) $max }}
                    <li class="rank-item">
                        <div class="rank-item-text">
                            <a class="rank-item-link" href="https://{{ $label }}/" target="_blank">
                                <img src="https://favicone.com/{{ $label }}?s=50" />
                                {{ $label }}
                            </a>
                            <span class="rank-item-count font-mono">{{ $count }}</span>
                        </div>
                        <div class="rank-item-bar" style="width:{{ $percent }}%"></div>
                    </li>
                {{ end }}
            {{ end }}
            </ol>
        </section>
    </article>
    {{ partial "footer.html" . }}
{{ end }}