Hugo

Hugo FixIt 主题美化实践

FixIt 主题支持通过多种方式自定义样式与布局:

  • 自定义样式:在 assets/css/ 下创建 _override.scss(覆盖主题变量)和 _custom.scss(添加自定义 CSS),主题会自动加载。
  • 自定义脚本:在 assets/js/ 创建 custom.js 会在每个页面末尾自动执行,其它 JS 文件需在 [params.page.library.js] 中配置路径。
  • 模板覆盖:将主题 layouts/ 下的文件复制到项目根目录相同路径,Hugo 会优先使用新模板。
  • 自定义块:在 layouts/_partials/ 下创建任意 .html 文件,并在 [params.customPartials] 中启用,主题会自动渲染到页面相应位置。

下面介绍如何利用这些自定义能力,为 FixIt 博客注入个性化元素。1

全局

样式覆盖

FixIt 2026.5.19 | 更改

定义流体字体档位、响应式间距基准、亮 / 暗双主题颜色变量,并覆盖全局字号、暗黑模式、简化媒体查询 mixin 及分类标签样式。

创建以下文件:

SCSSassets/css/_override.scss
  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
:root {
  // 字号
  --c-font-base: clamp(0.96875rem, 0.85rem + 0.2vw, 1rem);
  --c-font-xxs: calc(0.625 * var(--c-font-base));
  --c-font-xs: calc(0.75  * var(--c-font-base));
  --c-font-s: calc(0.875 * var(--c-font-base));
  --c-font-m: var(--c-font-base); 
  --c-font-l: calc(1.125 * var(--c-font-base));
  --c-font-xl: calc(1.25 * var(--c-font-base));
  --c-font-xxl: calc(1.5 * var(--c-font-base));
  --c-font-xxxl: calc(1.75 * var(--c-font-base));

  // 边距
  --c-space-1: 0.25rem;   /* 1 unit = 4px */
  --c-space-2: calc(var(--c-space-1) * 2);    /* 0.5rem */
  --c-space-4: calc(var(--c-space-1) * 4);    /* 1rem   */
  --c-space-6: calc(var(--c-space-1) * 6);    /* 1.5rem */
  --c-space-8: calc(var(--c-space-1) * 8);    /* 2rem   */
  --c-space-10: calc(var(--c-space-1) * 10);  /* 2.5rem */
  --c-space-12: calc(var(--c-space-1) * 12);  /* 3rem   */

  @media (max-width: 680px) { --c-space-1: 0.22rem; }
  @media (min-width: 681px) and (max-width: 1200px) { --c-space-1: 0.23rem; }

  // 颜色
  --c-global-font-color: #333;

  --c-card-bg: #fefefe;
  --c-card-border: #e5e7eb; 
  --c-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --c-card-shadow-hover: 0 12px 24px -8px rgba(0, 0, 0, 0.12);
  --c-card-border-hover: rgba(0, 0, 0, 0.08);

  --c-header-bg: rgba(255, 255, 255, 0.68);
  --c-header-border: rgba(0, 0, 0, 0.06);
  --c-header-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);

  --c-meta: #8b949e;
  --c-meta-alt: #3a3a44;
  --c-meta-hover: #000;
  --c-meta-bg: rgba(0, 0, 0, 0.05);
  --c-meta-bg-hover: rgba(0, 0, 0, 0.1);

  --c-category-tech: #2376b7; 
  --c-category-tech-hover: #1a5a8a;
  --c-category-tech-bg: rgba(35, 118, 183, 0.12);
  --c-category-tech-bg-hover: rgba(35, 118, 183, 0.2);  

  --c-category-work: #28a050;
  --c-category-work-hover: #1e6e3a;
  --c-category-work-bg: rgba(40, 160, 80, 0.12);
  --c-category-work-bg-hover: rgba(40, 160, 80, 0.2);
  
  --c-category-life: #e6781e;
  --c-category-life-hover: #b85c12;
  --c-category-life-bg: rgba(230, 120, 30, 0.12);
  --c-category-life-bg-hover: rgba(230, 120, 30, 0.2);

  --c-postinfo-bg: #fafbfc;
  --c-postinfo-border: rgba(0, 0, 0, 0.06);
  --c-avatar-bg: #fefefe;
  --c-avatar-border: #e0e4e8;
  --c-avatar-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --c-avatar-shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.12);
  --c-reward-btn-bg: #e65c3c;
  --c-reward-btn-hover: #c94b2c;
  --c-subscribe-btn-bg: #45b37a;
  --c-subscribe-btn-hover: #3ab47a;

  --c-link: #2376b7;
  --c-link-hover: #ea517f;  
  --c-toc-font: #161209;
  --c-collection-bg: #fefefe;
  --c-collection-border: #f0f0f0;

  --tooltip-bg: #fefefe;
  --tooltip-color: #0f172a;
  --c-update-badge-bg: #ff5722;
  --c-book-corner-bg: #f99b01;
  --c-book-corner-shadow: rgba(0, 0, 0, 0.2);
  --c-book-corner-pseudo: #e68900;
  --c-star-full: #ffac2d;
  --c-star-empty: #ddd;
}

[data-theme="dark"] {
  // 颜色
  --c-global-font-color: #c0c0c0;
  
  --c-card-bg: #35373c;
  --c-card-border: #46494f;
  --c-card-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
  --c-card-shadow-hover: 0 16px 28px -8px rgba(0, 0, 0, 0.35);
  --c-card-border-hover: rgba(255, 255, 255, 0.1);  

  --c-header-bg: rgba(46, 47, 51, 0.8);
  --c-header-border: rgba(255, 255, 255, 0.04); 
  --c-header-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);

  --c-meta: #7d8792;
  --c-meta-alt: #c0c0c8;
  --c-meta-hover: #ffffff;
  --c-meta-bg: rgba(255, 255, 255, 0.08);
  --c-meta-bg-hover: rgba(255, 255, 255, 0.15);

  --c-category-tech: #1781b5;
  --c-category-tech-hover: #2a8fbf;
  --c-category-tech-bg: rgba(23, 129, 181, 0.2);
  --c-category-tech-bg-hover: rgba(23, 129, 181, 0.3);

  --c-category-work: #8ad6a8;
  --c-category-work-hover: #6ec08a;
  --c-category-work-bg: rgba(60, 180, 100, 0.2);
  --c-category-work-bg-hover: rgba(60, 180, 100, 0.3);
  
  --c-category-life: #f5bc7a;
  --c-category-life-hover: #e09c5a;
  --c-category-life-bg: rgba(240, 150, 60, 0.2);
  --c-category-life-bg-hover: rgba(240, 150, 60, 0.3);

  --c-postinfo-bg: #2f3136;
  --c-postinfo-border: rgba(255, 255, 255, 0.06);
  --c-avatar-bg: #2f3136;
  --c-avatar-border: #5a5e66;
  --c-avatar-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --c-avatar-shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.5);
  --c-reward-btn-bg: #a5452a;
  --c-reward-btn-hover: #c55a3a;
  --c-subscribe-btn-bg: #1e6d3a;
  --c-subscribe-btn-hover: #155a2e;

  --c-link: #1781b5;
  --c-link-hover: #cc5595;
  --c-toc-font: #b1b1ba;
  --c-collection-bg: #292a2e;
  --c-collection-border: #383838;

  --tooltip-bg: #39393c;
  --tooltip-color: #e2e2e6;  
  --c-update-badge-bg: #cc4a1a;
  --c-book-corner-bg: #b84b00;
  --c-book-corner-shadow: rgba(0, 0, 0, 0.4);
  --c-book-corner-pseudo: #963b00;
  --c-star-full: #ffac2d;
  --c-star-empty: #ddd;
}

创建以下文件:

SCSSassets/css/_custom.scss
 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
// ========= 全局 =========

// 字体
body { font-size: var(--c-font-m); color: var(--c-global-font-color); }
h1 { font-size: var(--c-font-xxl); }
h2 { font-size: var(--c-font-xl); }
h3, h4 { font-size: var(--c-font-l); }

// 暗黑模式
[data-theme="dark"] { img:not(.no-darken) { filter: brightness(0.95); } }
[data-theme="dark"] { #bgCanvas, #flyfish canvas { filter: brightness(0.85) saturate(1.1); } }
[data-theme="dark"] { .single .content { b, strong { color: #c8c8c8; } } }

// 设备响应使用方法:@include phone { } @include pad { } @include pc { } */
@mixin phone { @media (max-width: 680px) { @content; } } 
@mixin pad { @media (min-width: 681px) and (max-width: 1200px) { @content; } } 
@mixin pc { @media (min-width: 1201px) { @content; } } 

// 分类标签使用方法:@include category-color-styles;
@mixin category-color-styles {
  $cats: tech, work, life;
  @each $cat in $cats {
    &[href*="/#{$cat}/"] {
      color: var(--c-category-#{$cat});
      background-color: var(--c-category-#{$cat}-bg);

      &:hover {
        color: var(--c-category-#{$cat}-hover);
        background-color: var(--c-category-#{$cat}-bg-hover);
      }
    }
  }
}

背景彩带

生成流动丝带效果,Canvas 叠于页面最底层,半透明适配深浅主题。2

创建以下文件:

JavaScriptassets/js/ribbons.js
  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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
// ribbons.js - 适配 FixIt 主题的丝带效果
(function (name, factory) {
  if (typeof window === "object") {
    window[name] = factory();
  }
})("Ribbons", function () {
  var _w = window,
    _b = document.body,
    _d = document.documentElement;

  // 随机函数
  var random = function () {
    if (arguments.length === 1) {
      if (Array.isArray(arguments[0])) {
        var index = Math.round(random(0, arguments[0].length - 1));
        return arguments[0][index];
      }
      return random(0, arguments[0]);
    } else if (arguments.length === 2) {
      return Math.random() * (arguments[1] - arguments[0]) + arguments[0];
    }
    return 0;
  };

  // 屏幕信息
  var screenInfo = function (e) {
    var width = Math.max(
        0,
        _w.innerWidth || _d.clientWidth || _b.clientWidth || 0,
      ),
      height = Math.max(
        0,
        _w.innerHeight || _d.clientHeight || _b.clientHeight || 0,
      ),
      scrollx =
        Math.max(0, _w.pageXOffset || _d.scrollLeft || _b.scrollLeft || 0) -
        (_d.clientLeft || 0),
      scrolly =
        Math.max(0, _w.pageYOffset || _d.scrollTop || _b.scrollTop || 0) -
        (_d.clientTop || 0);
    return {
      width: width,
      height: height,
      ratio: width / height,
      centerx: width / 2,
      centery: height / 2,
      scrollx: scrollx,
      scrolly: scrolly,
    };
  };

  var mouseInfo = function (e) {
    var screen = screenInfo(e),
      mousex = e ? Math.max(0, e.pageX || e.clientX || 0) : 0,
      mousey = e ? Math.max(0, e.pageY || e.clientY || 0) : 0;

    return {
      mousex: mousex,
      mousey: mousey,
      centerx: mousex - screen.width / 2,
      centery: mousey - screen.height / 2,
    };
  };

  // 点
  var Point = function (x, y) {
    this.x = 0;
    this.y = 0;
    this.set(x, y);
  };
  // 点运算
  Point.prototype = {
    constructor: Point,
    set: function (x, y) {
      this.x = x || 0;
      this.y = y || 0;
    },
    copy: function (point) {
      this.x = point.x || 0;
      this.y = point.y || 0;
      return this;
    },
    multiply: function (x, y) {
      this.x *= x || 1;
      this.y *= y || 1;
      return this;
    },
    divide: function (x, y) {
      this.x /= x || 1;
      this.y /= y || 1;
      return this;
    },
    add: function (x, y) {
      this.x += x || 0;
      this.y += y || 0;
      return this;
    },
    subtract: function (x, y) {
      this.x -= x || 0;
      this.y -= y || 0;
      return this;
    },
    clampX: function (min, max) {
      this.x = Math.max(min, Math.min(this.x, max));
      return this;
    },
    clampY: function (min, max) {
      this.y = Math.max(min, Math.min(this.y, max));
      return this;
    },
    flipX: function () {
      this.x *= -1;
      return this;
    },
    flipY: function () {
      this.y *= -1;
      return this;
    },
  };

  // 丝带画板
  var Factory = function (options) {
    this._canvas = null;
    this._context = null;
    this._sto = null;
    this._width = 0;
    this._height = 0;
    this._scroll = 0;
    this._ribbons = [];
    this._options = {
      id: "bgCanvas", //画板Id
      backgroundColor: "transparent", // 修改点1: 透明背景适配所有主题
      colorSaturation: "80%", //纯度
      colorBrightness: "75%", //修改点2: 提高亮度使深色模式更协调
      colorAlpha: 0.15, // 修改点3: 降低透明度避免遮挡内容
      colorCycleSpeed: 6, //丝带不同块之间的色彩变化量
      verticalPosition: "center", //丝带相对于屏幕的初始位置
      horizontalSpeed: 200, //丝带水平方向移动速度参数
      ribbonCount: 3, //同一时间丝带总条数
      strokeSize: 0, //公共边路径样式
      parallaxAmount: -0.99, //滚动偏移参数
      animateSections: true, //丝带块是否偏移,显得有动感
    };
    this._onDraw = this._onDraw.bind(this);
    this._onResize = this._onResize.bind(this);
    this._onScroll = this._onScroll.bind(this);
    this.setOptions(options);
    this.init();
  };
  Factory.prototype = {
    constructor: Factory,
    setOptions: function (options) {
      if (typeof options === "object") {
        for (var key in options) {
          if (options.hasOwnProperty(key)) {
            this._options[key] = options[key];
          }
        }
      }
    },
    //初始化
    init: function () {
      //初始化画板
      try {
        this._canvas = document.createElement("canvas");
        this._canvas.style["display"] = "block";
        this._canvas.style["position"] = "fixed";
        this._canvas.style["margin"] = "0";
        this._canvas.style["padding"] = "0";
        this._canvas.style["border"] = "0";
        this._canvas.style["outline"] = "0";
        this._canvas.style["left"] = "0";
        this._canvas.style["top"] = "0";
        this._canvas.style["width"] = "100%";
        this._canvas.style["height"] = "100%";
        // 修改点4: 降低层级在飞鱼之下
        this._canvas.style["z-index"] = "-2";
        this._canvas.style["background-color"] = this._options.backgroundColor;
        this._canvas.id = this._options.id;
        this._onResize();
        this._context = this._canvas.getContext("2d");
        this._context.clearRect(0, 0, this._width, this._height);
        this._context.globalAlpha = this._options.colorAlpha;
        window.addEventListener("resize", this._onResize);
        window.addEventListener("scroll", this._onScroll);
        document.body.appendChild(this._canvas);
      } catch (e) {
        console.warn("Canvas Context Error: " + e.toString());
        return;
      }
      //开始绘画
      this._onDraw();
    },
    //生成一条丝带
    addRibbon: function () {
      var dir = Math.round(random(1, 9)) > 5 ? "right" : "left", //丝带延伸方向
        stop = 1000,
        hide = 200,
        min = 0 - hide,
        max = this._width + hide,
        movex = 0,
        movey = 0,
        startx = dir === "right" ? min : max, //起始点x左边
        starty = Math.round(random(0, this._height)); //起始点y左边

      //丝带生成的位置
      if (/^(top|min)$/i.test(this._options.verticalPosition)) {
        //最上方
        starty = 0 + hide;
      } else if (/^(middle|center)$/i.test(this._options.verticalPosition)) {
        //中间
        starty = this._height / 2;
      } else if (/^(bottom|max)$/i.test(this._options.verticalPosition)) {
        //最下方
        starty = this._height - hide;
      }

      if (this._options.parallaxAmount !== 0) {
        starty += this._scroll; //加上滚动
      }

      var ribbon = [],
        point1 = new Point(startx, starty),
        point2 = new Point(startx, starty),
        point3 = null,
        color = Math.round(random(0, 360)),
        delay = 0;

      //从起始位置开始生成一条丝带
      while (true) {
        if (stop <= 0) break;
        stop--;
        movex = Math.round(
          (Math.random() * 1 - 0.2) * this._options.horizontalSpeed,
        );
        movey = Math.round((Math.random() * 1 - 0.5) * (this._height * 0.25));
        point3 = new Point();
        point3.copy(point2);
        if (dir === "right") {
          point3.add(movex, movey);
          if (point2.x >= max) break;
        } else if (dir === "left") {
          point3.subtract(movex, movey);
          if (point2.x <= min) break;
        }
        ribbon.push({
          point1: new Point(point1.x, point1.y),
          point2: new Point(point2.x, point2.y),
          point3: point3,
          color: color, //丝带颜色
          delay: delay, //延迟消失
          dir: dir, //方向
          alpha: 0, //透明度
          phase: 0, //随机位移有关参数
        });
        point1.copy(point2);
        point2.copy(point3);
        delay += 4;
        color += this._options.colorCycleSpeed;
      }
      this._ribbons.push(ribbon);
    },
    //绘制一个三角形方块
    _drawRibbonSection: function (section) {
      if (section) {
        if (section.phase >= 1 && section.alpha <= 0) {
          return true;
        }
        if (section.delay <= 0) {
          section.phase += 0.02;
          section.alpha = Math.sin(section.phase) * 1;
          section.alpha = section.alpha <= 0 ? 0 : section.alpha;
          section.alpha = section.alpha >= 1 ? 1 : section.alpha;
          if (this._options.animateSections) {
            var mod = Math.sin(1 + (section.phase * Math.PI) / 2) * 0.1;
            if (section.dir === "right") {
              section.point1.add(mod, 0);
              section.point2.add(mod, 0);
              section.point3.add(mod, 0);
            } else {
              section.point1.subtract(mod, 0);
              section.point2.subtract(mod, 0);
              section.point3.subtract(mod, 0);
            }
            section.point1.add(0, mod);
            section.point2.add(0, mod);
            section.point3.add(0, mod);
          }
        } else {
          section.delay -= 0.5;
        }
        var s = this._options.colorSaturation,
          l = this._options.colorBrightness,
          c =
            "hsla(" +
            section.color +
            ", " +
            s +
            ", " +
            l +
            ", " +
            section.alpha +
            " )";

        //绘制一个方块
        this._context.save();
        if (this._options.parallaxAmount !== 0) {
          this._context.translate(
            0,
            this._scroll * this._options.parallaxAmount,
          );
        }
        this._context.beginPath();
        this._context.moveTo(section.point1.x, section.point1.y);
        this._context.lineTo(section.point2.x, section.point2.y);
        this._context.lineTo(section.point3.x, section.point3.y);
        this._context.fillStyle = c;
        this._context.fill();
        if (this._options.strokeSize > 0) {
          this._context.lineWidth = this._options.strokeSize;
          this._context.strokeStyle = c;
          this._context.lineCap = "round";
          this._context.stroke();
        }
        this._context.restore();
      }
      return false;
    },
    //绘制丝带
    _onDraw: function () {
      //清空已经绘制过的丝带
      for (var i = 0, t = this._ribbons.length; i < t; ++i) {
        if (!this._ribbons[i]) {
          this._ribbons.splice(i, 1);
        }
      }
      this._context.clearRect(0, 0, this._width, this._height); //清空画板
      for (var a = 0; a < this._ribbons.length; ++a) {
        var ribbon = this._ribbons[a],
          numSections = ribbon ? ribbon.length : 0,
          numDone = 0;

        //绘制整条丝带
        for (var b = 0; b < numSections; ++b) {
          if (this._drawRibbonSection(ribbon[b])) {
            numDone++;
          }
        }
        //丝带已经全部飘过屏幕,设置为null,函数前面会自动清理
        if (numDone >= numSections) {
          this._ribbons[a] = null;
        }
      }
      //随机生成一条丝带
      if (
        this._ribbons.length < this._options.ribbonCount &&
        Math.random() > 0.99
      ) {
        this.addRibbon();
      }

      //调度交给系统,当需要刷新画板时调用指定的回调函数,用于提高性能
      requestAnimationFrame(this._onDraw);
    },
    //重新设置窗体大小时需要获取窗体大小
    _onResize: function (e) {
      var screen = screenInfo(e);
      this._width = screen.width;
      this._height = screen.height;
      if (this._canvas) {
        this._canvas.width = this._width;
        this._canvas.height = this._height;
        if (this._context) {
          this._context.globalAlpha = this._options.colorAlpha;
        }
      }
    },
    //滚动时获取滚动距离
    _onScroll: function (e) {
      var screen = screenInfo(e);
      this._scroll = screen.scrolly;
    },
  };
  return Factory;
});

//初始化并绘制 - 添加飞鱼层级保护
// 修改点5: 确保飞鱼在丝带之上
document.addEventListener("DOMContentLoaded", function () {
  // 初始化丝带效果
  new Ribbons({
    ribbonCount: 4, // 修改点6: 减少丝带数量
    parallaxAmount: -0.99,
  });

  // 确保飞鱼在丝带之上
  setTimeout(function () {
    var flyfish = document.getElementById("flyfish");
    if (flyfish) {
      flyfish.style.zIndex = "-1";
    }
  }, 1000);
});

修改主题配置:

TOMLconfig/_default/hugo.toml
1
2
[params.page.library.js]
ribbons = "/js/ribbons.js"

创建以下文件(可选):

SCSSassets/css/_custom.scss
1
[data-theme="dark"] { #bgCanvas { filter: brightness(0.85) saturate(1.1); } }

页脚飞鱼

在页脚生成游动鱼群动画,根据暗色模式自动切换填充色。3

创建以下文件:

JavaScriptassets/js/flyfish.js
  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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
/**
 * 源码来自互联网,作者不详
 * @modified by Lruihao 2024-05-21 移除依赖 jQuery
 * @description 一个鱼游动的动画效果
 */
const RENDERER = {
  POINT_INTERVAL: 5,
  FISH_COUNT: 3,
  MAX_INTERVAL_COUNT: 50,
  INIT_HEIGHT_RATE: 0.5,
  THRESHOLD: 50,

  init: function () {
    this.setParameters();
    this.setStyle();
    this.reconstructMethods();
    this.setup();
    this.bindEvent();
    this.render();
  },
  setParameters: function () {
    this.window = window;
    this.container = document.createElement("div");
    this.container.id = "flyfish";
    this.canvas = document.createElement("canvas");
    this.context = this.canvas.getContext("2d");
    this.points = [];
    this.fishes = [];
    this.watchIds = [];
    document.querySelector(".footer").appendChild(this.container);
  },
  setStyle: function () {
    const style = document.createElement("style");
    style.innerHTML = `
      .footer {
        position: relative;
      }
      #flyfish {
        position: absolute;
        width: 100%;
        height: 250px;
        overflow: hidden;
        left: 0;
        bottom: 0;
        z-index: -1;
        pointer-events: none;
      }`;
    document.querySelector("head").appendChild(style);
  },
  createSurfacePoints: function () {
    const count = Math.round(this.width / this.POINT_INTERVAL);
    this.pointInterval = this.width / (count - 1);
    this.points.push(new SURFACE_POINT(this, 0));

    for (let i = 1; i < count; i++) {
      const point = new SURFACE_POINT(this, i * this.pointInterval),
        previous = this.points[i - 1];

      point.setPreviousPoint(previous);
      previous.setNextPoint(point);
      this.points.push(point);
    }
  },
  reconstructMethods: function () {
    this.watchWindowSize = this.watchWindowSize.bind(this);
    this.jdugeToStopResize = this.jdugeToStopResize.bind(this);
    this.startEpicenter = this.startEpicenter.bind(this);
    this.moveEpicenter = this.moveEpicenter.bind(this);
    this.render = this.render.bind(this);
  },
  setup: function () {
    this.points.length = 0;
    this.fishes.length = 0;
    this.watchIds.length = 0;
    this.intervalCount = this.MAX_INTERVAL_COUNT;

    this.containerWidth = this.container.offsetWidth;
    this.containerHeight = this.container.offsetHeight;
    this.width = this.containerWidth;
    this.height = this.containerHeight;
    this.fishCount =
      (((this.FISH_COUNT * this.width) / 500) * this.height) / 500;
    this.canvas.width = this.width;
    this.canvas.height = this.height;
    this.reverse = false;

    this.container.appendChild(this.canvas);
    this.fishes.push(new FISH(this));
    this.createSurfacePoints();
  },
  watchWindowSize: function () {
    this.clearTimer();
    this.tmpWidth = this.window.innerWidth;
    this.tmpHeight = this.window.innerHeight;
    this.watchIds.push(setTimeout(this.jdugeToStopResize, this.WATCH_INTERVAL));
  },
  clearTimer: function () {
    while (this.watchIds.length > 0) {
      clearTimeout(this.watchIds.pop());
    }
  },
  jdugeToStopResize: function () {
    const width = this.window.innerWidth,
      height = this.window.innerHeight,
      stopped = width == this.tmpWidth && height == this.tmpHeight;

    this.tmpWidth = width;
    this.tmpHeight = height;

    if (stopped) {
      this.setup();
    }
  },
  bindEvent: function () {
    const self = this;
    this.window.addEventListener("resize", function () {
      self.watchWindowSize();
    });
    this.container.addEventListener("mouseenter", function (event) {
      self.startEpicenter(event);
    });
    this.container.addEventListener("mousemove", function (event) {
      self.moveEpicenter(event);
    });
  },
  getAxis: function (event) {
    const offset = this.container.getBoundingClientRect();

    return {
      x: event.clientX - offset.left + this.window.scrollX,
      y: event.clientY - offset.top + this.window.scrollY,
    };
  },
  startEpicenter: function (event) {
    this.axis = this.getAxis(event);
  },
  moveEpicenter: function (event) {
    const axis = this.getAxis(event);

    if (!this.axis) {
      this.axis = axis;
    }
    this.generateEpicenter(axis.x, axis.y, axis.y - this.axis.y);
    this.axis = axis;
  },
  generateEpicenter: function (x, y, velocity) {
    if (
      y < this.height / 2 - this.THRESHOLD ||
      y > this.height / 2 + this.THRESHOLD
    ) {
      return;
    }
    const index = Math.round(x / this.pointInterval);

    if (index < 0 || index >= this.points.length) {
      return;
    }
    this.points[index].interfere(y, velocity);
  },
  controlStatus: function () {
    for (let i = 0, count = this.points.length; i < count; i++) {
      this.points[i].updateSelf();
    }
    for (let i = 0, count = this.points.length; i < count; i++) {
      this.points[i].updateNeighbors();
    }
    if (this.fishes.length < this.fishCount) {
      if (--this.intervalCount == 0) {
        this.intervalCount = this.MAX_INTERVAL_COUNT;
        this.fishes.push(new FISH(this));
      }
    }
  },
  render: function () {
    const self = this;
    function renderFrame() {
      self.controlStatus();
      self.context.clearRect(0, 0, self.width, self.height);
      // 这里利用 FixIt 主题的 isDark 属性来判断是否是暗色主题
      if (fixit.isDark) {
        self.context.fillStyle = "rgb(255 255 255 / 10%)";
      } else {
        self.context.fillStyle = "#e6e5f8";
      }

      for (let i = 0, count = self.fishes.length; i < count; i++) {
        self.fishes[i].render(self.context);
      }
      self.context.save();
      self.context.globalCompositeOperation = "xor";
      self.context.beginPath();
      self.context.moveTo(0, self.reverse ? 0 : self.height);

      for (let i = 0, count = self.points.length; i < count; i++) {
        self.points[i].render(self.context);
      }
      self.context.lineTo(self.width, self.reverse ? 0 : self.height);
      self.context.closePath();
      self.context.fill();
      self.context.restore();

      requestAnimationFrame(renderFrame);
    }
    renderFrame();
  },
};

// SURFACE_POINT class
function SURFACE_POINT(renderer, x) {
  this.renderer = renderer;
  this.x = x;
  this.init();
}
SURFACE_POINT.prototype = {
  SPRING_CONSTANT: 0.03,
  SPRING_FRICTION: 0.9,
  WAVE_SPREAD: 0.3,
  ACCELARATION_RATE: 0.01,

  init: function () {
    this.initHeight = this.renderer.height * this.renderer.INIT_HEIGHT_RATE;
    this.height = this.initHeight;
    this.fy = 0;
    this.force = { previous: 0, next: 0 };
  },
  setPreviousPoint: function (previous) {
    this.previous = previous;
  },
  setNextPoint: function (next) {
    this.next = next;
  },
  interfere: function (y, velocity) {
    this.fy =
      this.renderer.height *
      this.ACCELARATION_RATE *
      (this.renderer.height - this.height - y >= 0 ? -1 : 1) *
      Math.abs(velocity);
  },
  updateSelf: function () {
    this.fy += this.SPRING_CONSTANT * (this.initHeight - this.height);
    this.fy *= this.SPRING_FRICTION;
    this.height += this.fy;
  },
  updateNeighbors: function () {
    if (this.previous) {
      this.force.previous =
        this.WAVE_SPREAD * (this.height - this.previous.height);
    }
    if (this.next) {
      this.force.next = this.WAVE_SPREAD * (this.height - this.next.height);
    }
  },
  render: function (context) {
    if (this.previous) {
      this.previous.height += this.force.previous;
      this.previous.fy += this.force.previous;
    }
    if (this.next) {
      this.next.height += this.force.next;
      this.next.fy += this.force.next;
    }
    context.lineTo(this.x, this.renderer.height - this.height);
  },
};

// FISH class
function FISH(renderer) {
  this.renderer = renderer;
  this.init();
}
FISH.prototype = {
  GRAVITY: 0.4,

  init: function () {
    this.direction = Math.random() < 0.5;
    this.x = this.direction
      ? this.renderer.width + this.renderer.THRESHOLD
      : -this.renderer.THRESHOLD;
    this.previousY = this.y;
    this.vx = this.getRandomValue(4, 10) * (this.direction ? -1 : 1);

    if (this.renderer.reverse) {
      this.y = this.getRandomValue(
        (this.renderer.height * 1) / 10,
        (this.renderer.height * 4) / 10,
      );
      this.vy = this.getRandomValue(2, 5);
      this.ay = this.getRandomValue(0.05, 0.2);
    } else {
      this.y = this.getRandomValue(
        (this.renderer.height * 6) / 10,
        (this.renderer.height * 9) / 10,
      );
      this.vy = this.getRandomValue(-5, -2);
      this.ay = this.getRandomValue(-0.2, -0.05);
    }
    this.isOut = false;
    this.theta = 0;
    this.phi = 0;
  },
  getRandomValue: function (min, max) {
    return min + (max - min) * Math.random();
  },
  controlStatus: function (context) {
    this.previousY = this.y;
    this.x += this.vx;
    this.y += this.vy;
    this.vy += this.ay;

    if (this.renderer.reverse) {
      if (this.y > this.renderer.height * this.renderer.INIT_HEIGHT_RATE) {
        this.vy -= this.GRAVITY;
        this.isOut = true;
      } else {
        if (this.isOut) {
          this.ay = this.getRandomValue(0.05, 0.2);
        }
        this.isOut = false;
      }
    } else {
      if (this.y < this.renderer.height * this.renderer.INIT_HEIGHT_RATE) {
        this.vy += this.GRAVITY;
        this.isOut = true;
      } else {
        if (this.isOut) {
          this.ay = this.getRandomValue(-0.2, -0.05);
        }
        this.isOut = false;
      }
    }
    if (!this.isOut) {
      this.theta += Math.PI / 20;
      this.theta %= Math.PI * 2;
      this.phi += Math.PI / 30;
      this.phi %= Math.PI * 2;
    }
    this.renderer.generateEpicenter(
      this.x + (this.direction ? -1 : 1) * this.renderer.THRESHOLD,
      this.y,
      this.y - this.previousY,
    );

    if (
      (this.vx > 0 && this.x > this.renderer.width + this.renderer.THRESHOLD) ||
      (this.vx < 0 && this.x < -this.renderer.THRESHOLD)
    ) {
      this.init();
    }
  },
  render: function (context) {
    context.save();
    context.translate(this.x, this.y);
    context.rotate(Math.PI + Math.atan2(this.vy, this.vx));
    context.scale(1, this.direction ? 1 : -1);
    context.beginPath();
    context.moveTo(-30, 0);
    context.bezierCurveTo(-20, 15, 15, 10, 40, 0);
    context.bezierCurveTo(15, -10, -20, -15, -30, 0);
    context.fill();

    context.save();
    context.translate(40, 0);
    context.scale(0.9 + 0.2 * Math.sin(this.theta), 1);
    context.beginPath();
    context.moveTo(0, 0);
    context.quadraticCurveTo(5, 10, 20, 8);
    context.quadraticCurveTo(12, 5, 10, 0);
    context.quadraticCurveTo(12, -5, 20, -8);
    context.quadraticCurveTo(5, -10, 0, 0);
    context.fill();
    context.restore();

    context.save();
    context.translate(-3, 0);
    context.rotate(
      (Math.PI / 3 + (Math.PI / 10) * Math.sin(this.phi)) *
        (this.renderer.reverse ? -1 : 1),
    );

    context.beginPath();

    if (this.renderer.reverse) {
      context.moveTo(5, 0);
      context.bezierCurveTo(10, 10, 10, 30, 0, 40);
      context.bezierCurveTo(-12, 25, -8, 10, 0, 0);
    } else {
      context.moveTo(-5, 0);
      context.bezierCurveTo(-10, -10, -10, -30, 0, -40);
      context.bezierCurveTo(12, -25, 8, -10, 0, 0);
    }
    context.closePath();
    context.fill();
    context.restore();
    context.restore();
    this.controlStatus(context);
  },
};

window.onload = function () {
  RENDERER.init();
};

修改主题配置:

TOMLconfig/_default/hugo.toml
1
2
[params.page.library.js]
flyfish = "/js/flyfish.js"

创建以下文件(可选):

SCSSassets/css/_custom.scss
1
[data-theme="dark"] { #flyfish canvas { filter: brightness(0.85) saturate(1.1); } }

首页

FixIt 2026.5.8 | 更改

按最后修改时间排序,自定义卡片布局(左侧封面图 + 右侧标题 / 分类 / 合集 / 日期),移除摘要、作者、阅读全文和标签;当文章有更新时,右上角显示更新斜飘带角标。

创建以下文件:

HTMLlayouts/home.html
  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
171
{{- /* 覆盖来源:FixIt/layouts/home.html */ -}}

{{- define "title" -}}
  {{- .Site.Title -}}
  {{- if .Site.Params.indexWithSubtitle | and .Site.Params.header.subtitle.name -}}
    {{- printf " - %v" .Site.Params.header.subtitle.name -}}
  {{- end -}}
{{- end -}}

{{- define "content" -}}
  {{- $params := partial "function/params.html" -}}
  {{- $profile := .Site.Params.home.profile -}}
  {{- $posts := .Site.Params.home.posts -}}
  {{- $pages := slice -}}

  {{- /* Paginate calculation */ -}}
  {{- if ne $posts.enable false -}}
    {{- $pages = .Site.Store.Get "mainSectionPages" -}}
    {{- if .Site.Params.page.hiddenFromHomePage -}}
      {{- $pages = where $pages "Params.hiddenfromhomepage" false -}}
    {{- else -}}
      {{- $pages = where $pages "Params.hiddenfromhomepage" "!=" true -}}
    {{- end -}}

    {{- /* ======================== 修改点 1:开始 ======================== */ -}}
    {{- /* 按最后修改时间降序(如果未设置 lastmod 则回退到发布日期) */ -}}
    {{- $pages = $pages.ByLastmod.Reverse -}}
    {{- /* ======================== 修改点 1:结束 ======================== */ -}}

    {{- with $posts.paginate | default .Site.Params.paginate -}}
      {{- $pages = $.Paginate $pages . -}}
    {{- else -}}
      {{- $pages = .Paginate $pages -}}
    {{- end -}}
  {{- end -}}

  <div class="page home{{ if ne $posts.enable false }} posts{{ end }}">
    {{- /* Only show profile and content on first page */ -}}
    {{- if (not $profile.onlyFirstPage) | or (eq $.Paginator.PageNumber 1) -}}
      {{- /* Profile */ -}}
      {{- if ne $profile.enable false -}}
        {{- partial "home/profile.html" . -}}
      {{- end -}}

      {{- /* Content */ -}}
      {{- if .Content -}}
        <div class="single">
          <div class="content" id="content">
            {{- dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
          </div>
        </div>
      {{- end -}}
    {{- end -}}

    {{- /* Paginate rendering */ -}}
    {{- if ne $posts.enable false -}}
      {{- range $pages.Pages -}}

        {{- /* ======================== 修改点 2:开始 ======================== */ -}}
        {{- /* 日期计算(必须在卡片循环内,以便 $isUpdated 可用) */ -}}
        {{- $dateFormat := "2006/01/02" -}}
        {{- $publishDate := .PublishDate -}}
        {{- $lastmodDate := .Lastmod -}}
        {{- $displayDate := $publishDate -}}
        {{- $isUpdated := false -}}
        {{- if $lastmodDate -}}
          {{- if $lastmodDate.After $publishDate -}}
            {{- $displayDate = $lastmodDate -}}
            {{- $isUpdated = true -}}
          {{- end -}}
        {{- end -}}
        {{- /* 自定义卡片布局 */ -}}
        {{- $pageParams := .Params | merge $.Site.Params.page -}}
        <article class="custom-summary" itemscope itemtype="http://schema.org/Article">
          {{- /* 右上角更新角标 */ -}}
          {{- if $isUpdated -}}
            <div class="update-badge">
              <span>更新</span>
            </div>
          {{- end -}}      
          {{- /* 左侧封面图 */ -}}
          {{- $imagams.featuredimagepreview | default $pageParams.featuredimage -}}
          {{- $matches := slice -}}
          {{- if .Resources.GetMatch "featured-image-preview" -}}
            {{- $matches = $matches | append "featured-image-preview" -}}
          {{- else if .Resources.GetMatch "featured-image" -}}
            {{- $matches = $matches | append "featured-image" -}}
          {{- end -}}
          {{- if $image | or (gt (len $matches) 0) -}}
            <div class="featured-image-preview">
              <a href="{{ .RelPermalink }}" aria-label="{{ .Title }}">
                {{- $optim := slice
                  (dict "Process" "fill 240x160 Center webp" "descriptor" "240w")
                  (dict "Process" "fill 480x320 Center webp" "descriptor" "480w")
                  (dict "Process" "fill 720x480 Center webp" "descriptor" "720w")
                -}}
                {{- dict "Src" $image "Title" .Title "Resources" .Resources "Matches" $matches "Loading" "eager" "Width" "240" "Height" "160" "Sizes" "(max-width: 680px) 100px, 120px" "OptimConfig" $optim "Alt" (printf "Featured image for %v" .Title) | partial "plugin/image.html" -}}
              </a>
            </div>
          {{- end -}}
          {{- /* 右侧内容区 */ -}}
          <div class="summary-content" style="position: relative;">
            {{- /* 标题 */ -}}
            <h2 class="single-title{{ if $isUpdated }} has-update{{ end }}" itemprop="name headline">
              {{- with $pageParams.weight -}}
                {{- $icon := dict "Class" "fa-solid fa-thumbtack" -}}
                <span title="{{ T "single.pin" }}" class="icon-pin">{{- $icon | partial "plugin/icon.html" -}}</span>
              {{- end -}}
              {{- $repost := $pageParams.repost | default dict -}}
              {{- with $repost -}}
                {{- if eq .Enable true -}}
                  {{- $icon := dict "Class" "fa-solid fa-share" -}}
                  {{- $title := cond (hasPrefix .Url "http") (printf "%v -> %v" (T "single.repost") .Url ) (T "single.repost") -}}
                  <span title="{{ $title }}" class="icon-repost">{{- $icon | partial "plugin/icon.html" -}}</span>
                {{- end -}}
              {{- end -}}
              <a href="{{ .RelPermalink }}">{{ cond (.Param "capitalizeTitles") (title .Title) .Title }}</a>
            </h2>
            {{- /* 摘要:有内容时才显示 */ -}}
            <!--
            {{- if or .Summary .Description -}}
              <div class="content">
                {{- if .Summary -}}
                  {{- $plainify := (.Param "summaryPlainify") | default false -}}
                  {{- with .Markup "home" -}}
                    {{- with .Render -}}
                      {{- $summary := dict "Content" .Summary.Text "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
                      {{- cond $plainify ($summary | plainify) $summary -}}
                    {{- end -}}
                  {{- end -}}
                {{- else -}}
                  {{- .Description | safeHTML -}}
                {{- end -}}
              </div>
            {{- end -}}
            -->           
            {{- /* 底部行:分类/合集 + 日期 */ -}}
            <div class="post-footer-row">
              <div class="post-categories">
                {{- $categories := .GetTerms "categories" -}}
                {{- $collections := .GetTerms "collections" -}}
                {{- if or $categories $collections -}}
                  {{- range $categories -}}
                    <a href="{{ .RelPermalink }}" class="post-category-link">
                      {{- dict "Class" "fa-regular fa-folder" | partial "plugin/icon.html" -}}
                      {{- .LinkTitle -}}
                    </a>
                  {{- end -}}
                  {{- range $collections -}}
                    <a href="{{ .RelPermalink }}" class="post-category-link">
                      {{- dict "Class" "fa-solid fa-layer-group" | partial "plugin/icon.html" -}}
                      {{- .LinkTitle -}}
                    </a>
                  {{- end -}}
                {{- end -}}
              </div>
              <div class="post-date">
                <time datetime="{{ $displayDate.Format "2006-01-02" }}" title='{{ $displayDate.Format "2006-01-02 15:04:05" }}'>
                  {{- $displayDate.Format $dateFormat -}}
                </time>
              </div>
            </div>
          </div>
        </article>
        {{- /* ======================== 修改点 2:结束 ======================== */ -}}
        
      {{- end -}}
      {{- partial "paginator.html" . -}}
    {{- end -}}
  </div>
{{- end -}}

创建以下文件:

SCSSassets/css/_custom.scss
  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
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 首页 =========

.home.posts {
  width: 100%;
  margin-block: var(--c-space-4);
  max-width: clamp(360px, 85vw, 700px);

  .home-profile {
    .home-title {
      font-size: var(--c-font-xxl);
    }
  }

  .custom-summary {
    padding: 0;
    display: flex;
    overflow: hidden;
    position: relative;
    border-radius: 16px;
    margin-block: var(--c-space-8);
    box-shadow: var(--c-card-shadow);
    background-color: var(--c-card-bg);
    border: 1px solid var(--c-card-border);
    transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
    
    &:hover {
      transform: translateY(-2px);
      box-shadow: var(--c-card-shadow-hover);
      border-color: var(--c-card-border-hover);
    }

    &::before, 
    &::after {
      padding: 0;
      display: none;
      content: none;
    }

    &:last-of-type {
      margin-bottom: 0;
    }

    .update-badge {
      position: absolute;
      top: 0;
      right: 0;
      z-index: 10;
      width: 70px;
      height: 70px;
      overflow: hidden;
      pointer-events: none;

      span {
        position: absolute;
        top: 6px;
        right: -24px;
        color: #fff;
        padding: 0 28px;
        font-weight: 600;
        white-space: nowrap;
        letter-spacing: 1px;
        transform: rotate(45deg);
        text-transform: uppercase;
        font-size: var(--c-font-xs);
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        background-color: var(--c-update-badge-bg);
      }
    }

    .featured-image-preview {
      margin: 0;
      height: auto;
      width: 200px;
      overflow: hidden;
      aspect-ratio: 2 / 1;
      border-radius: 16px 0 0 16px;
      @include phone { width: 90px; aspect-ratio: 4 / 3; }

      img {
        height: 100% !important;
        transition: transform 0.3s ease;

        &:hover {
          transform: scale(1.2);
        }        
      }
    }

    .summary-content {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: calc(var(--c-space-1) * 3);
      padding: calc(var(--c-space-1) * 3); 

      .single-title {
        margin: 0;
        width: 100%;
        line-height: 1.5;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: var(--c-font-l);

        &.has-update {
          max-width: calc(100% - 20px);
        }
      }

      /*.content {
        line-clamp: 2;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        text-overflow: ellipsis;
        -webkit-box-orient: vertical;
      }*/
    }

    .post-footer-row {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;

      .post-categories {
        display: flex;
        flex-wrap: wrap;
        gap: var(--c-space-2);
      }

      a {   
        border-radius: 14px;
        align-items: center;
        transition: all 0.3s;
        display: inline-flex;
        text-decoration: none;
        gap: var(--c-space-1);
        color: var(--c-meta-alt);
        font-size: var(--c-font-xs);
        background-color: var(--c-meta-bg);
        padding: var(--c-space-1) var(--c-space-2);
        @include category-color-styles;

        &:hover {
          color: var(--c-meta-hover);
          background-color: var(--c-meta-bg-hover);
        }
      }      
      
      .post-date {
        white-space: nowrap;  
        color: var(--c-meta);
        font-size: var(--c-font-xs);
      }        
    }    
  }    
}

归档页

同首页卡片布局(custom-archive),按年分组显示文章列表。

创建以下文件:

HTMLlayouts/_partial/custom-post-list.html
 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
{{- $page := . -}}
{{- $showLastmod := false -}}
{{- /* 如果页面上下文中有来自最近更新的标记,则显示更新日期 */ -}}
{{- if $page.Scratch.Get "fromRecentlyUpdated" -}}
  {{- $showLastmod = true -}}
{{- end -}}

{{- /* 自定义卡片布局 */ -}}    
<article class="custom-archive">
  <!-- 左侧封面图:从 front matter 中读取 featuredImage -->
  {{- if $page.Params.featuredImage -}}
    <div class="archive-item-image">
      <a href="{{ $page.RelPermalink }}" class="archive-image-link">
        {{- $img := $page.Params.featuredImage -}}
        {{- $imageResource := resources.GetMatch (printf "images/%s" (path.Base $img)) -}}
        {{- if $imageResource -}}
          {{- $thumbnail := $imageResource.Fill "600x400 Center" -}}
          <img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" alt="{{ $page.Title }}" loading="lazy">
        {{- else -}}
          <img src="{{ $img | safeURL }}" alt="{{ $page.Title }}" loading="lazy">
        {{- end -}}
      </a>
    </div>
  {{- end -}}
  <!-- 左侧内容区:日期和标题 -->
  <div class="archive-item-content">
    <span class="archive-item-date" title='{{ if $showLastmod }}{{ $page.Lastmod.Format "2006-01-02 15:04:05" }}{{ else }}{{ $page.Date.Format "2006-01-02 15:04:05" }}{{ end }}'>
      {{- dict "Class" "far fa-calendar-alt me-1" | partial "plugin/icon.html" -}}
      {{- if $showLastmod -}}
        {{- $page.Lastmod | dateFormat "01-02" -}}
      {{- else -}}
        {{- $page.Date | dateFormat "01-02" -}}
      {{- end -}}
    </span>
    <a href="{{ $page.RelPermalink }}" class="archive-item-link">
      {{- $repost := $page.Params.repost | default dict -}}
      {{- if eq $repost.enable true -}}
        {{- dict "Class" "fa-solid fa-share text-success me-1" | partial "plugin/icon.html" -}}
      {{- end -}}
      {{- cond ($page.Param "capitalizeTitles") (title $page.LinkTitle) $page.LinkTitle -}}
    </a>
  </div>
</article>

创建以下文件:

HTMLlayouts/home.archives.html
 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
{{- /* 覆盖来源:FixIt/layouts/home.archives.html */ -}}

{{- define "title" -}}
  {{- .Params.Title | default (T "archives") -}}
  {{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}}
{{- end -}}

{{- define "content" -}}
  {{- /* All Posts */ -}}
  {{- $pages := .Site.Store.Get "mainSectionPages" -}}

  <div class="page archive">
    <div class="header">
      {{- /* Title */ -}}
      <h1 class="single-title animate__animated animate__pulse animate__faster">
        {{- dict "Class" "fa-solid fa-box-archive me-1" | partial "plugin/icon.html" -}}
        {{- .Params.Title | default (T "archives") }} <sup>{{ $pages.Len }}</sup>
      </h1>
      {{- /* Total word count */ -}}
      {{- /* See https://github.com/hugo-fixit/FixIt/issues/124 */ -}}
      {{- $localData := newScratch -}}
      {{- range $pages -}}
        {{- $localData.Add "totalWordCount" .WordCount -}}
      {{- end -}}
      {{- with ($localData.Get "totalWordCount") -}}
        {{- $humanizedNum := . -}}
        {{- if ge $humanizedNum 1000 -}}
          {{- $humanizedNum = printf "%.2fK" (div $humanizedNum 1000.0) -}}
        {{- end -}}
        <p class="single-subtitle total-word-count" title='{{- T "section.totalWordCount" . }}'>
          {{- dict "Class" "fa-regular fa-keyboard" | partial "plugin/icon.html" }} {{ T "section.totalWordCount" (dict "Count" $humanizedNum) -}}
        </p>
      {{- end -}}
    </div>

    {{- /* Paginate */ -}}
    {{- if $pages -}}
      {{- $pages = $pages.GroupByDate "2006" -}}
      {{- with .Site.Params.archives.paginate | default .Site.Params.paginate -}}
        {{- $pages = $.Paginate $pages . -}}
      {{- else -}}
        {{- $pages = .Paginate $pages -}}
      {{- end -}}
      {{- partial "recently-updated.html" . -}}
      {{- range $pages.PageGroups -}}
        <h2 class="group-title">
          {{- dict "Class" "fa-regular fa-calendar me-1" | partial "plugin/icon.html" -}}
          {{- .Key -}}
        </h2>

        {{- /* ======================== 修改点 1:开始 ======================== */ -}}
        {{- /* 自定义卡片布局:全部迁移至独立 partial "custom-post-list.html */ -}}      
        {{- range .Pages -}}
          {{- partial "custom-post-list.html" . -}}
        {{- end -}}
        {{- /* ======================== 修改点 1:结束 ======================== */ -}} 

      {{- end -}}
      {{- partial "paginator.html" . -}}
    {{- end -}}
  </div>
{{- end -}}

创建以下文件:

HTMLlayouts/term.html
 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
{{- /* 覆盖来源:FixIt/layouts/term.html */ -}}

{{- define "title" -}}
  {{- .Title }} - {{ T .Data.Singular | default .Data.Singular -}}
  {{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}}
{{- end -}}

{{- define "content" -}}
  <div class="page archive">
    {{- /* Title */ -}}
    {{- $taxonomy := .Data.Singular -}}
    {{- $pageCount := len .Pages -}}
    {{- $termIcon := "" -}}
    {{- $termTitle := .Title -}}
    {{- if eq $taxonomy "category" -}}
      {{- $termIcon = "fa-regular fa-folder-open" -}}
    {{- else if eq $taxonomy "tag" -}}
      {{- $termIcon = "fa-solid fa-tag" -}}
    {{- else if eq $taxonomy "collection" -}}
      {{- $termIcon = "fa-solid fa-layer-group" -}}
    {{- else -}}
      {{- $termTitle = printf "%v - %v" (T $taxonomy | default $taxonomy) .Title -}}
    {{- end -}}
    <h1 class="single-title animate__animated animate__pulse animate__faster">
      {{- with $termIcon -}}
        {{- dict "Class" (add . " me-1") | partial "plugin/icon.html" -}}
      {{- end -}}
      {{- $termTitle }} <sup>{{ $pageCount }}</sup>
    </h1>

    {{- /* Paginate */ -}}
    {{- if .Pages -}}
      {{- $pages := .Pages.GroupByDate "2006" -}}
      {{- with .Site.Params.list.paginate | default .Site.Params.paginate -}}
        {{- $pages = $.Paginate $pages . -}}
      {{- else -}}
        {{- $pages = .Paginate $pages -}}
      {{- end -}}
      {{- partial "recently-updated.html" . -}}
      {{- range $pages.PageGroups -}}
        <h2 class="group-title">
          {{- dict "Class" "fa-regular fa-calendar me-1" | partial "plugin/icon.html" -}}
          {{- .Key -}}
        </h2>

        {{- /* ======================== 修改点 1:开始 ======================== */ -}}
        {{- /* 自定义卡片布局:全部迁移至独立 partial "custom-post-list.html */ -}}      
        {{- range .Pages -}}
          {{- partial "custom-post-list.html" . -}}
        {{- end -}}
        {{- /* ======================== 修改点 1:结束 ======================== */ -}} 

        {{- end -}}
      {{- end -}}
      {{- partial "paginator.html" . -}}
    {{- end -}}
  </div>
{{- end -}}

创建以下文件:

HTMLlayouts/section.html
 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
{{- define "title" -}}
  {{- title (.Params.Title | default ((T .Section) | default .Section | dict "Some" | T "allSome")) -}}
  {{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}}
{{- end -}}

{{- define "content" -}}
  <div class="page archive">
    <div class="header">
      {{- /* Title */ -}}
      <h1 class="single-title animate__animated animate__pulse animate__faster">
        {{- $titleIcon := "fa-solid fa-feather" -}}
        {{- with .Params.titleIcon -}}
          {{- $titleIcon = . -}}
        {{- end -}}
        {{- dict "Class" (add $titleIcon " me-1") | partial "plugin/icon.html" -}}
        {{- title (.Params.Title | default ((T .Section) | default .Section | dict "Some" | T "allSome")) }} <sup>{{ .Pages.Len }}</sup>
      </h1>
      {{- /* Total word count */ -}}
      {{- /* See https://github.com/hugo-fixit/FixIt/issues/124 */ -}}
      {{- $localData := newScratch -}}
      {{- range .Pages -}}
        {{- $localData.Add "totalWordCount" .WordCount -}}
      {{- end -}}
      {{- with ($localData.Get "totalWordCount") -}}
        {{- $humanizedNum := . -}}
        {{- if ge $humanizedNum 1000 -}}
          {{- $humanizedNum = printf "%.2fK" (div $humanizedNum 1000.0) -}}
        {{- end -}}
        <p class="single-subtitle total-word-count" title='{{- T "section.totalWordCount" . }}'>
          {{- dict "Class" "fa-regular fa-keyboard" | partial "plugin/icon.html" }} {{ T "section.totalWordCount" (dict "Count" $humanizedNum) -}}
        </p>
      {{- end -}}
    </div>

    {{- /* Paginate */ -}}
    {{- if .Pages -}}
      {{- $pages := .Pages.GroupByDate "2006" -}}
      {{- with .Site.Params.section.paginate | default .Site.Params.paginate -}}
        {{- $pages = $.Paginate $pages . -}}
      {{- else -}}
        {{- $pages = .Paginate $pages -}}
      {{- end -}}
      {{- partial "recently-updated.html" . -}}
      {{- range $pages.PageGroups -}}
        <h2 class="group-title">
          {{- dict "Class" "fa-regular fa-calendar me-1" | partial "plugin/icon.html" -}}
          {{- .Key -}}
        </h2>

        {{- /* ======================== 修改点 1:开始 ======================== */ -}}
        {{- /* 自定义卡片布局:全部迁移至独立 partial "custom-post-list.html */ -}}      
        {{- range .Pages -}}
          {{- partial "custom-post-list.html" . -}}
        {{- end -}}
        {{- /* ======================== 修改点 1:结束 ======================== */ -}} 

      {{- end -}}
      {{- partial "paginator.html" . -}}
    {{- end -}}
  </div>
{{- end -}}

创建以下文件:

HTMLlayouts/_partials/recently-updated.html
 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
{{- /* 覆盖来源:FixIt/layouts/_partials/recently-updated.html */ -}}

{{- /* Recently updated pages for archives, section and term list */ -}}
{{- $kindMap := dict
  "home" "archives"
  "section" "section"
  "term" "list"
-}}
{{- $recentlyUpdatedConfig := .Site.Params.recentlyUpdated -}}
{{- $scope := index $kindMap .Kind -}}
{{- $scopeEnable := index $recentlyUpdatedConfig $scope | default false -}}
{{- if $scopeEnable | and (eq $.Paginator.PageNumber 1) -}}
  {{- $hasTitle := false }}
  {{- $postCount := 0 -}}
  {{- $maxPostCount := $recentlyUpdatedConfig.maxCount | default 10 -}}
  {{- $days := $recentlyUpdatedConfig.days | default 30 -}}
  {{- $dateformat := (index .Site.Params $scope).dateformat | default "01-02" -}}
  {{- $scopePages := .Pages -}}
  {{- if eq $scope "archives" -}}
    {{- $scopePages = .Site.Store.Get "mainSectionPages" -}}
  {{- end -}}
  {{- $scopePages = where $scopePages.ByLastmod.Reverse "Section" "!=" "" -}}
  {{- $hiddenAdapters := .Param "hiddenAdapters" | default false -}}
  {{- if $hiddenAdapters -}}
    {{- $scopePages = where $scopePages "File.IsContentAdapter" "ne" true -}}
  {{- end -}}
  {{- range first $maxPostCount $scopePages -}}
    {{- if gt (add .Lastmod.Unix (mul 86900 $days)) now.Unix -}}
      {{- if ne .Lastmod.Unix .Date.Unix }}
        {{- $postCount = add $postCount 1 -}}
        {{- if eq $hasTitle false -}}
          <h2 class="group-title">
            {{- dict "Class" "fa-regular fa-calendar-check me-1" | partial "plugin/icon.html" -}}
            {{- T "section.recentlyUpdated" -}}
          </h2>
          {{- $hasTitle = true -}}
        {{- end -}}

        {{- /* ======================== 修改点 1:开始 ======================== */ -}}
        {{- /* 自定义卡片布局:全部迁移至独立 partial "custom-post-list.html */ -}}      
        {{- .Scratch.Set "fromRecentlyUpdated" true -}}
        {{- partial "custom-post-list.html" . -}}
        {{- .Scratch.Delete "fromRecentlyUpdated" -}}
        {{- /* ======================== 修改点 1:结束 ======================== */ -}} 
        
      {{- end -}}
    {{- end -}}
  {{- end -}}
{{- end -}}

创建以下文件:

SCSSassets/css/_custom.scss
 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
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 归档页 =========

.special,
.archive {
  width: 100%;
  border-radius: 16px;
  box-sizing: border-box;
  background-color: var(--c-card-bg);
  max-width: clamp(360px, 85vw, 800px);
  border: 1px solid var(--c-card-border);
  padding: var(--c-space-8) var(--c-space-6);
  box-shadow: 0 2px 10px var(--c-card-shadow);  
  margin-block: var(--c-space-4) var(--c-space-8);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  @include phone { padding: var(--c-space-6) var(--c-space-4); }

  .single-title {
    padding: 0;
    font-size: var(--c-font-xxl);
    margin-block: var(--c-space-6);
  }

  .single-subtitle,
  .group-title {
    font-size: var(--c-font-xl);
  }

  .custom-archive {
    display: flex;
    align-items: center;
    gap: var(--c-space-2);
    box-sizing: border-box;  
    margin: var(--c-space-4);    
    justify-content: space-between;

    &:last-of-type {
      margin-bottom: var(--c-space-6);
    }

    .archive-item-image {
      width: 140px;
      flex-shrink: 0;
      overflow: hidden;
      border-radius: 8px;
      aspect-ratio: 2 / 1;
      @include phone { width: 80px; aspect-ratio: 4 / 3; }
      @include pad { width: 110px; aspect-ratio: 5 / 3; }

      img {
        height: 100%;
        transition: transform 0.3s ease;

        &:hover {
          transform: scale(1.15);
        }
      }
    }

    .archive-item-content {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: var(--c-space-1);

      .archive-item-date {
        text-align: left;       
        font-size: var(--c-font-s);
      }
        
      .archive-item-link {
        &:hover {
          color: var(--c-link-hover);
        }
      }
    }      
  }
}

合集页

手风琴折叠布局,展示全部合集,按最后修改时间降序排列,移除更多链接。

创建以下文件:

HTMLlayouts/taxonomies.html
 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
{{- /* 覆盖来源:FixIt/layouts/taxonomies.html */ -}}

{{- /* Taxonomies Page */ -}}
{{- $iconMap := dict
  "category" "fa-regular fa-folder"
  "collection" "fa-solid fa-layer-group"
-}}
{{- $icon := index $iconMap .Data.Singular | default $iconMap.category -}}

{{- /* ======================== 修改点 1:开始 ======================== */ -}}
{{- /* 手风琴折叠布局:每个项是一个折叠面板,默认收起,点击展开 */ -}}
{{- range .Data.Terms.ByCount -}}
  {{- $term := .Term -}}
  {{- $pages := .Pages -}}
  {{- with $.Site.GetPage "taxonomy" (printf "%v/%v" $.Type $term) -}}
  <div class="custom-taxonomy">
    {{- /* 折叠控制:使用 checkbox + label 实现互斥折叠(JS 确保同时只能展开一个) */ -}}
    <input type="checkbox" id="taxonomy-{{ $term | urlize }}" class="taxonomy-toggle">
    <label class="taxonomy-header" for="taxonomy-{{ $term | urlize }}">
      <div class="taxonomy-title">
        {{- .Page.Title -}}
        <span class="taxonomy-count">({{ len $pages }})</span>
      </div>
      <div class="taxonomy-icon">
        <i class="fas fa-chevron-down"></i>
      </div>
    </label>
    {{- /* 文章列表排序与显示 */ -}}
    <div class="taxonomy-content">
      {{- /* 按最后修改时间降序排序 */ -}}
      {{- $pages = sort $pages "Lastmod" "desc" -}}
      {{- /* 遍历该合集下的全部文章 */ -}}
      {{- range $pages -}}
        <a href="{{ .RelPermalink }}" class="taxonomy-post-link">
          <span class="taxonomy-post-title">
            {{- $repost := .Params.repost | default dict -}}
            {{- if eq $repost.enable true -}}
              {{- dict "Class" "fa-solid fa-share text-success me-1" | partial "plugin/icon.html" -}}
            {{- end -}}
            {{- cond (.Param "capitalizeTitles") (title .LinkTitle) .LinkTitle -}}
          </span>
          {{- /* 显示最新日期(取 lastmod 和 date 中较晚者) */ -}}
          {{- $dateFormat := .Site.Params.dateFormat | default "2006-01-02" -}}
          {{- $publishDate := .PublishDate -}}
          {{- $lastmodDate := .Lastmod -}}
          {{- $displayDate := $publishDate -}}
          {{- if $lastmodDate -}}
            {{- if $lastmodDate.After $publishDate -}}
              {{- $displayDate = $lastmodDate -}}
            {{- end -}}
          {{- end -}}
          <span class="taxonomy-post-date" title='{{ $displayDate.Format "2006-01-02 15:04:05" }}'>
            {{- $displayDate.Format $dateFormat -}}
          </span>
        </a>
      {{- end -}}
      {{- /* 已删除更多链接 */ -}}
    </div>
  </div>
  {{- end -}}
{{- end -}}
{{- /* ======================== 修改点 1:结束 ======================== */ -}}

{{- /* EOF */ -}}

创建以下文件:

JavaScriptassets/js/custom.js
 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
(function() {

  // ========== 手风琴折叠(仅 taxonomy 页) ==========

  (function() {
    if (!document.querySelector('.custom-taxonomy')) return;

    setTimeout(function() {
      var headers = document.querySelectorAll('.custom-taxonomy .taxonomy-header');
      var checkboxes = document.querySelectorAll('.custom-taxonomy .taxonomy-toggle');
      var currentOpen = null;

      for (var i = 0; i < checkboxes.length; i++) {
        checkboxes[i].checked = false;
      }

      for (var i = 0; i < headers.length; i++) {
        headers[i].addEventListener('click', function(e) {
          e.preventDefault();
          var checkboxId = this.getAttribute('for');
          var checkbox = document.getElementById(checkboxId);
          var item = this.closest('.custom-taxonomy');
          if (!checkbox || !item) return;

          if (checkbox.checked) {
            checkbox.checked = false;
            currentOpen = null;
            return;
          }

          if (currentOpen) {
            var oldCheckbox = currentOpen.querySelector('.taxonomy-toggle');
            if (oldCheckbox) oldCheckbox.checked = false;
          }

          checkbox.checked = true;
          currentOpen = item;
        });
      }
    }, 50);
  })();

)();    

创建以下文件:

SCSSassets/css/_custom.scss
  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
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 合集页 =========

.custom-taxonomy {
  display: flex;
  overflow: hidden;
  gap: var(--c-space-2);
  flex-direction: column;
  margin-block: var(--c-space-2);
  border-bottom: 1px solid var(--c-card-border);

  &:last-of-type {
    border-bottom: none;
    margin-bottom: var(--c-space-6);
  }

 .taxonomy-toggle {
    display: none;

    &:checked + .taxonomy-header + .taxonomy-content {
      opacity: 1;
      max-height: none;
    }

    &:checked + .taxonomy-header {
      .taxonomy-title {
        color: var(--c-link);
      }

      .taxonomy-icon i {
        transform: rotate(180deg);
        font-size: var(--c-font-s);
      }
    }        
  }   

  .taxonomy-header {
    display: flex;
    cursor: pointer;
    user-select: none;
    border-radius: 8px;
    align-items: center;
    padding: var(--c-space-2);
    justify-content: space-between;
    transition: background 0.3s ease;
    
    &:hover {
      background: var(--c-meta-bg);
    }
   
    .taxonomy-title {
      font-weight: 600;
      color: var(--c-meta-alt);
      font-size: var(--c-font-l); 
    }

    .taxonomy-count {
      font-weight: normal;
      color: var(--c-meta);
      font-size: var(--c-font-s);
      margin-left: var(--c-space-2);
    }

    .taxonomy-icon i {
      color: var(--c-meta);
      transition: transform 0.3s ease-out;
    }
  }   

  .taxonomy-content {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    padding-inline: var(--c-space-4);

    .taxonomy-post-link {
      display: flex;
      line-height: 1.7;
      align-items: center;
      color: var(--c-meta-alt);       
      justify-content: space-between;

      &:hover {
        color: var(--c-link) !important;
      }

      &:last-of-type {
        margin-bottom: var(--c-space-4);
      }
    }

    .taxonomy-post-title {
      flex: 1; 
      min-width: 0; 
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;   
    }

    .taxonomy-post-date {
      flex-shrink: 0;
      white-space: nowrap;
      color: var(--c-meta);
      font-size: var(--c-font-xs);
      margin-left: var(--c-space-2);
    }    
  }       
}

文章页

双栏布局

左正文区 + 右目录,隐藏左侧边栏。

创建以下文件:

SCSSassets/css/_custom.scss
 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
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 文章页 =========

.single {
  width: 100%;
  border-radius: 16px;
  box-sizing: border-box;
  padding: var(--c-space-8);
  background-color: var(--c-card-bg);
  max-width: clamp(360px, 85vw, 800px);
  border: 1px solid var(--c-card-border);
  box-shadow: 0 2px 10px var(--c-card-shadow);  
  margin-block: var(--c-space-4) var(--c-space-8);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  @include phone { padding: var(--c-space-6); }
}

// ========= 目录 =========

// 隐藏静态目录 + 合集
#toc-static,
.aside-collection {
  display: none !important;
}

#toc-auto {
  padding: 0;
  overflow: hidden; 
  max-width: 280px;
  border-radius: 16px;
  margin-left: var(--c-space-2);
  top: calc(var(--c-space-8) * 2);
  box-shadow: var(--c-card-shadow);
  background-color: var(--c-card-bg);
  border: 1px solid var(--c-card-border);
  margin-block: var(--c-space-4) 0 !important;
  @include pad { display: none !important; }

  .toc-title {
    margin: 0;
    display: flex;
    margin-block: 0;
    align-items: center;
    background-color: transparent;
    justify-content: space-between; 
    font-size: var(--c-font-m) !important;
    padding: var(--c-space-2) var(--c-space-4);

    &::before {
      bottom: 0;
      margin-right: 0;
      content: "\f550";
      font-weight: 900;
      color: var(--c-toc-font);
      font-family: "Font Awesome 7 Free";
    }
  }

  .toc-content {
    margin-top: 0;
    overflow-y: auto;
    line-height: 1.7;
    scrollbar-width: thin;
    background-color: transparent;
    transition: box-shadow 0.3s ease;
    font-size: var(--c-font-s) !important;
    padding: var(--c-space-2) var(--c-space-6) var(--c-space-4);
  }
}

头部元数据

FixIt 2026.5.8 | 更改
  • 分类 / 合集:取自 Front matter 中的 categories / collections,移至标题上方。
  • 标题 / 副标题:分别取自 Front matter 的 titlesubtitle
  • 作者:由 [params.author] name 或 Front matter 的 author 控制。
  • 发布日期 / 更新日期:发布日期始终显示,格式受 dateFormat 配置影响;更新日期由 [params.page] showLastmod 控制是否显示。
  • 字数 / 阅读时间:由 [params.page]wordCount / readingTime 控制。
  • 访客数 / 评论数:由 [params.page.comment] 中启用的评论系统的对应开关控制。

创建以下文件:

HTMLlayouts/posts/single.html
  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
{{- /* 覆盖来源:FixIt/layouts/posts/single.html */ -}}

{{- define "title" -}}
  {{- cond (.Param "capitalizeTitles") (title .Title) .Title -}}
  {{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}}
{{- end -}}

{{- define "content" -}}
  {{- $title := cond (.Param "capitalizeTitles") (title .Title) .Title -}}
  {{- $params := partial "function/params.html" -}}
  {{- $toc := .Store.Get "toc" -}}
  {{- $tableOfContents := .Fragments.ToHTML ($toc.startlevel | int) ($toc.endlevel | int) ($toc.ordered | default false) -}}
  {{- $showToc := $toc.enable | and (ne $tableOfContents `<nav id="TableOfContents"></nav>`) -}}
  {{- .Store.Set "showToc" $showToc -}}
  {{- $tableOfContents = dict "Content" $tableOfContents "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}

  <aside class="aside-collection animate__animated animate__fadeIn animate__faster" aria-label="{{ T "collections" }}">
    {{- /* Collection List */ -}}
    {{- partial "single/collection-list.html" . -}}

    {{- /* Related Content */ -}}
    {{- partial "single/related-aside.html" . -}}

    {{- /* Custom Aside */ -}}
    {{- block "custom-aside" . }}{{ end -}}
  </aside>

  <article class="page single"{{ with .Params.fromAdapters }} data-adapters="{{ . }}"{{ end }}>

    {{- /* ======================== 修改点 1:开始 ======================== */ -}}
    {{- /* 重构文章头部:全部迁移至独立 partial "custom-single-header.html */ -}}
    {{- partial "custom-single-header.html" . -}}
    {{- /* ======================== 修改点 1:结束 ======================== */ -}}

    {{- /* Featured image */ -}}
    {{- $image := $params.featuredimage -}}
    {{- $matches := slice -}}
    {{- if .Resources.GetMatch "featured-image" -}}
      {{- $matches = $matches | append "featured-image" -}}
    {{- end -}}
    {{- if $image | or (gt (len $matches) 0) -}}
      <div class="featured-image">
        {{- $optim := slice 
          (dict "Process" "resize 800x webp" "descriptor" "800w")
          (dict "Process" "resize 1200x webp" "descriptor" "1200w")
          (dict "Process" "resize 1600x webp" "descriptor" "1600w") 
        -}}
        {{- dict "Src" $image "Title" $.Description "Resources" .Resources "Matches" $matches "Loading" "eager" "Sizes" "(max-width: 680px) 100vw, (max-width: 960px) 80vw, (max-width: 1440px) 56vw, 800px" "OptimConfig" $optim | partial "plugin/image.html" -}}
      </div>
    {{- end -}}

    {{- /* Static TOC */ -}}
    {{- if $showToc -}}
      <div class="details toc{{ with $params.password }} encrypted-hidden{{ end }}" id="toc-static" data-kept="{{ if $toc.keepstatic }}true{{ else }}false{{ end }}">
        <div class="details-summary toc-title">
          <span>{{ T "single.contents" }}</span>
          <span>{{ dict "Class" "details-icon fa-solid fa-angle-right" | partial "plugin/icon.html" }}</span>
        </div>
        <div class="details-content toc-content" id="toc-content-static">
          {{- $tableOfContents -}}
        </div>
      </div>
    {{- end -}}

    {{- /* AI Summary */ -}}
    {{- $summaryConfig := (.Params | merge .Site.Params).postSummary -}}
    {{- if $summaryConfig.enable -}}
      <div class="ai-summary"></div>
    {{- end -}}

    {{- /* Custom block before post content */ -}}
    {{- block "custom-post__content:before" . }}{{ end -}}

    {{- /* Expiration Reminder */ -}}
    {{- partial "single/expiration-reminder.html" . -}}

    {{- /* Content */ -}}
    {{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
    <div class="content" id="content"{{ with $params.endFlag }} data-end-flag="{{ . }}"{{ end }}>
      {{- if not $params.password -}}
        {{- $content -}}
      {{- end -}}
    </div>

    {{- /* Custom block after post content */ -}}
    {{- block "custom-post__content:after" . }}{{ end -}}

    {{- /* Related Content */ -}}
    {{- partial "single/related.html" . -}}

    {{- /* ======================== 修改点 2:开始 ======================== */ -}}
    {{- /* 已删除 Reward before Footer */ -}}
    {{- /* ======================== 修改点 2:结束 ======================== */ -}}

    {{- /* Content Encryption */ -}}
    {{- dict "Content" $content "Password" $params.password "Message" $params.message "Page" . | partial "plugin/fixit-encryptor.html" -}}

    {{- /* ======================== 修改点 3:开始 ======================== */ -}}
    {{- /* 已删除 Collection Navigation */ -}}
    {{- /* ======================== 修改点 3:结束 ======================== */ -}}

    {{- /* Custom block before post footer */ -}}
    {{- block "custom-post__footer:before" . }}{{ end -}}

    {{- /* Footer */ -}}
    {{- partial "single/footer.html" . -}}

    {{- /* ======================== 修改点 4:开始 ======================== */ -}}
    {{- /* 已删除 Reward after post footer */ -}}
    {{- /* ======================== 修改点 4:结束 ======================== */ -}}

    {{- /* Custom block after post footer */ -}}
    {{- block "custom-post__footer:after" . }}{{ end -}}

    {{- /* Comment */ -}}
    {{- partial "single/comment.html" . -}}
  </article>

  <aside class="toc" id="toc-auto" aria-label="{{ T "single.contents" }}">
    {{- /* Custom block before post toc */ -}}
    {{- block "custom-post__toc:before" . }}{{ end -}}

    {{- /* Auto TOC */ -}}
    {{- if $showToc -}}
      <h2 class="toc-title{{ with $params.password }} encrypted-hidden{{ end }}">
        {{- T "single.contents" -}}&nbsp;
        {{- dict "Class" "toc-icon fa-solid fa-angle-down" | partial "plugin/icon.html" -}}
      </h2>
      <div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}{{ with $params.password }} encrypted-hidden{{ end }}" id="toc-content-auto"></div>
    {{- end -}}

    {{- /* Custom block after post toc */ -}}
    {{- block "custom-post__toc:after" . }}{{ end -}}
  </aside>

  {{- /* TOC Dialog */ -}}
  {{- if $showToc -}}
    <dialog id="toc-dialog" aria-labelledby="toc-dialog-title" role="dialog">
      <div class="toc">
        <h2 class="toc-title">{{ T "single.contents" }}</h2>
        <div class="toc-content" id="toc-content-drawer">
          {{- replace $tableOfContents `id="TableOfContents"` "" | safeHTML -}}
        </div>
      </div>
    </dialog>
  {{- end -}}
{{- end -}}

创建以下文件:

HTMLlayouts/_partials/custom-single-header.html
  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
{{- /* 自定义块来源:FixIt/layouts/posts/single.html */ -}}

{{- $title := cond (.Param "capitalizeTitles") (title .Title) .Title -}}
{{- $params := partial "function/params.html" -}}
{{- $comment := .Store.Get "comment" | default dict -}}

{{- /* 分类和合集 */ -}}
{{- $categories := slice -}}
{{- range .GetTerms "categories" -}}
  {{- $url := partial "function/escapeurl.html" .RelPermalink -}}
  {{- $categories = $categories | append (printf `<a href="%s" class="post-category" title="%s - %s">%s %s</a>` $url (T "category") .LinkTitle (dict "Class" "fa-regular fa-folder" | partial "plugin/icon.html") .LinkTitle) -}}
{{- end -}}
{{- $collections := slice -}}
{{- range .GetTerms "collections" -}}
  {{- $url := partial "function/escapeurl.html" .RelPermalink -}}
  {{- $collections = $collections | append (printf `<a href="%s" class="post-collection" title="%s - %s">%s %s</a>` $url (T "collection") .LinkTitle (dict "Class" "fa-solid fa-layer-group" | partial "plugin/icon.html") .LinkTitle) -}}
{{- end -}}
{{- if or $categories $collections -}}
  <div class="post-top-meta">
    {{- delimit $categories " " | safeHTML -}}
    {{- if and $categories $collections -}} {{ end -}}
    {{- delimit $collections " " | safeHTML -}}
  </div>
{{- end -}}

{{- /* 标题 */ -}}
<h1 class="single-title animate__animated animate__flipInX">
  {{- $repost := $params.repost | default dict -}}
  {{- with $repost -}}
    {{- if eq .Enable true -}}
      {{- $icon := dict "Class" "fa-solid fa-share" -}}
      {{- $iconTitle := cond (hasPrefix .Url "http") (printf "%v -> %v" (T "single.repost") .Url ) (T "single.repost") -}}
      {{- if hasPrefix .Url "http" -}}
        {{ dict "Destination" .Url "Icon" $icon "Class" "icon-repost" "Title" $iconTitle | partial "plugin/link.html" -}}
      {{- else -}}
        <span title="{{ $iconTitle }}" class="icon-repost">{{- $icon | partial "plugin/icon.html" -}}</span>
      {{- end -}}
    {{- end -}}
  {{- end -}}
  <span>{{ $title }}</span>
</h1>

{{- /* 副标题 */ -}}
{{- with $params.subtitle -}}<p class="single-subtitle animate__animated animate__fadeIn">{{ . | $.RenderString }}</p>{{- end -}}

{{- /* 元数据 */ -}}
<div class="post-meta">
  {{- /* 作者 */ -}}
  {{- partial "single/post-author.html" . -}}
  {{- /* 发布日期 */ -}}
  {{- with .PublishDate | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
    <span title="{{ dict "Date" ("2006-01-02 15:04:05" | $.PublishDate.Format) | T "single.publishedOnDate" }}">
      {{- dict "Class" "fa-solid fa-calendar-days me-1" | partial "plugin/icon.html" -}}
      {{- printf `<time datetime="%v">%v</time>` . . | safeHTML -}}
    </span>
  {{- end -}}
  {{- /* 更新日期 */ -}}
  {{- if (ne .Lastmod.Unix .PublishDate.Unix) | and $params.showLastmod -}}
    {{- with .Lastmod | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
      <span title="{{ dict "Date" ("2006-01-02 15:04:05" | $.Lastmod.Format) | T "single.updatedOnDate" }}">
        {{- dict "Class" "fa-regular fa-calendar-check me-1" | partial "plugin/icon.html" -}}
        {{- printf `<time datetime="%v">%v</time>` . . | safeHTML -}}
      </span>
    {{- end -}}
  {{- end -}}
  {{- /* 字数 */ -}}
  {{- if $params.wordCount -}}
    <span title="{{ T "single.wordCount" .WordCount }}">
      {{- dict "Class" "fa-solid fa-pencil-alt me-1" | partial "plugin/icon.html" -}}
      {{- T "single.fuzzyWordCount" .FuzzyWordCount -}}
    </span>
  {{- end -}}
  {{- /* 阅读时间 */ -}}
  {{- if $params.readingTime -}}
    <span>
      {{- dict "Class" "fa-regular fa-clock me-1" | partial "plugin/icon.html" -}}
      约 {{ .ReadingTime }} 分钟
    </span>
  {{- end -}}
  {{- /* 访客数 */ -}}
  {{- $visitorIcon := dict "Class" "fa-regular fa-eye me-1" | partial "plugin/icon.html" -}}
  {{- if $comment.enable | and $comment.artalk.enable -}}
    <span class="comment-visitors" data-flag-title="{{ $title }}">
      {{- $visitorIcon }}<span class="artalk-visitor-count" data-page-key="{{ .RelPermalink }}">-</span>&nbsp;{{ T "single.views" }}
    </span>
  {{- else if $comment.enable | and $comment.valine.enable | and $comment.valine.visitor -}}
    <span id="{{ .RelPermalink }}" class="leancloud_visitors comment-visitors" data-flag-title="{{ $title }}">
      {{- $visitorIcon }}<span class="leancloud-visitors-count">-</span>&nbsp;{{ T "single.views" }}
    </span>
  {{- else if $comment.enable | and $comment.waline.enable | and $comment.waline.pageview -}}
    <span class="comment-visitors" data-flag-title="{{ $title }}">
      {{- $visitorIcon }}<span data-path="{{ .RelPermalink }}" class="waline-pageview-count">-</span>&nbsp;{{ T "single.views" }}
    </span>
  {{- else if $comment.enable | and $comment.twikoo.enable | and $comment.twikoo.visitor -}}
    <span id="{{ .RelPermalink }}" class="comment-visitors" data-flag-title="{{ $title }}">
      {{- $visitorIcon }}<span id="twikoo_visitors">-</span>&nbsp;{{ T "single.views" }}
    </span>
  {{- else if .Site.Params.busuanzi.enable | and .Site.Params.busuanzi.pageViews | and hugo.IsProduction -}}
    <span id="busuanzi_container_page_pv" class="busuanzi_visitors comment-visitors" data-flag-title="{{ $title }}">
      {{- $visitorIcon }}<span id="busuanzi_value_page_pv">-</span>&nbsp;{{ T "single.views" }}
    </span>
  {{- end -}}
  {{- /* 评论数 */ -}}
  {{- $commentIcon := dict "Class" "fa-regular fa-comments me-1" | partial "plugin/icon.html" -}}
  {{- if $comment.enable -}}
    {{- if $comment.artalk.enable -}}
      <span class="comment-count" data-flag-title="{{ $title }}">
        {{ $commentIcon }}<span class="artalk-comment-count" data-page-key="{{ .RelPermalink }}">-</span>&nbsp;{{ T "single.comments" }}
      </span>
    {{- else if $comment.valine.enable | and $comment.valine.commentCount -}}
      <span class="comment-count" data-flag-title="{{ $title }}">
        {{ $commentIcon }}<span data-xid="{{ .RelPermalink }}" class="valine-comment-count">-</span>&nbsp;{{ T "single.comments" }}
      </span>
    {{- else if $comment.waline.enable | and $comment.waline.comment -}}
      <span class="comment-count" data-flag-title="{{ $title }}">
        {{ $commentIcon }}<span data-path="{{ .RelPermalink }}" class="waline-comment-count">-</span>&nbsp;{{ T "single.comments" }}
      </span>
    {{- else if $comment.twikoo.enable | and $comment.twikoo.commentCount -}}
      <span id="{{ .RelPermalink }}" class="comment-count" data-flag-title="{{ $title }}">
        {{ $commentIcon }}<span id="twikoo-comment-count">-</span>&nbsp;{{ T "single.comments" }}
      </span>
    {{- end -}}
  {{- end -}}
</div>

创建以下文件:

SCSSassets/css/_custom.scss
 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
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 文章页 =========

.single {
  .post-top-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--c-space-2);
    font-size: var(--c-font-s);
    margin-block: var(--c-space-2);
    @include media('print') { display: none; }

    .post-category,
    .post-collection {
      border-radius: 14px;
      align-items: center;
      display: inline-flex;
      transition: all 0.3s;
      text-decoration: none;  
      gap: var(--c-space-2); 
      color: var(--c-meta-alt);   
      background-color: var(--c-meta-bg);  
      padding: var(--c-space-1) var(--c-space-2);
       
      &:hover {
        color: var(--c-meta-hover);
        background-color: var(--c-meta-bg-hover);
      }
    }

    .post-category {
      @include category-color-styles;
    }
  }

  .single-title {
    padding: 0;
    line-height: 1.6;
    font-size: var(--c-font-xxl); 
    @include media('print') { margin-block: var(--c-space-4) var(--c-space-2); }
  } 

  .post-meta {
    color: var(--c-meta);
    font-size: var(--c-font-s); 
    margin-block: var(--c-space-2);

    span {
      margin-right: var(--c-space-2);

      &:last-child {
        margin-right: 0;
      }      
    }

    a {
      color: var(--c-meta) !important; 

      &:hover {
        color: var(--c-meta) !important;  
      }
    }
  }
}

文末信息卡片

FixIt 2026.5.8 | 更改
  • 作者卡片:头像(带链接)、昵称、个人简介(优先使用 home.profile.subtitle)。
  • 赞赏 / 订阅:赞赏由 [params.page.reward] 控制,订阅 RSS 始终显示。
  • 版权声明:使用主题 [params.page] license 配置的 HTML。
  • 分享模块:由 [params.page.share] 控制,包括 Facebook、X、微信(wechat = true)、微博、复制链接(copy = true)五个固定按钮(微信和复制为自定义,其余三个复用主题)。
  • 上下页导航:沿用 [params.navigation]inSection / reverse 逻辑,显示下上下篇标题。
  • 合集卡片:由 [params.page.collectionNavigation] 控制,展示与当前文章时间邻近的 6 篇同合集文章(含封面、日期、标题)。
  • 评论区标题:固定显示为留言交流,无配置项。

创建以下文件:

HTMLlayouts/_partials/custom-single-footer.html
  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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
{{- /* 自定义块来源:FixIt/layouts/_partials/home/profile.html */ -}}
{{- /* 自定义块来源:FixIt/layouts/_partials/single/footer.html */ -}}
{{- /* 自定义块来源:FixIt/layouts/_partials/single/collection-nav.html */ -}}
{{- /* 自定义块来源:FixIt/layouts/_partials/single/reward.html */ -}}
{{- /* 自定义块来源:FixIt/layouts/_partials/plugin/reward.html */ -}}
{{- /* 自定义块来源:FixIt/layouts/_partials/plugin/share.html */ -}}

{{- $params := partial "function/params.html" -}}
{{- $profile := .Site.Params.home.profile -}}
{{- $author := partial "function/get-author-map.html" .Params.author -}}
{{- $avatar := "" -}}
{{- if $profile.gravatarEmail -}}
  {{- $avatar = dict "Email" $profile.gravatarEmail "Size" "96" | partial "function/get-gravatar.html" -}}
{{- end -}}
{{- if not $avatar -}}
  {{- $avatar = $profile.avatarURL | default "" -}}
{{- end -}}
{{- if not $avatar -}}
  {{- $avatar = $author.avatar | default "" -}}
{{- end -}}
{{- $authorName := $author.name | default .Site.Params.author.name | default "作者" -}}
{{- $authorBio := $profile.subtitle | default .Site.Params.description | default "" -}}
{{- $reward := .Store.Get "reward" | default dict -}}

{{- /* 文末信息卡片:作者信息 + 赞赏 / 订阅 + 版权 + 分享 */ -}}
<div class="custom-post-footer">
  {{- /* 作者头像 */ -}}
  <div class="avatar-frame">
    {{- if $avatar -}}
      {{- $avatarLink := .Site.BaseURL -}}
      {{- $menus := $.Site.Menus.main | default slice -}}
      {{- if $profile.avatarMenu -}}
        {{- range $menus -}}
          {{- if eq .Identifier $profile.avatarMenu -}}
            {{- $avatarLink = .URL | relLangURL -}}
            {{- with .Page -}}
              {{- $avatarLink = .RelPermalink -}}
            {{- end -}}
          {{- end -}}
        {{- end -}}
      {{- end -}}
      <a href="{{ $avatarLink }}">
        <img class="avatar" src="{{ $avatar }}" alt="author avatar">
      </a>
    {{- else -}}
      <div class="avatar-placeholder"></div>
    {{- end -}}
  </div>
  {{- /* 作者信息 */ -}}
  <div class="author-info">
    <div class="author-name">{{ $authorName }}</div>
    <div class="author-bio">{{ $authorBio }}</div>
  </div>
  {{- /* 动态按钮 */ -}}
  <div class="action-buttons">
    {{- /* 赞赏 */ -}}
    {{- if $reward.enable -}}
      <div class="post-reward">
        <div class="reward-button">
          {{- dict "Class" "fa-solid fa-qrcode" | partial "plugin/icon.html" -}}
          {{- T "single.reward.donate" -}}
        </div>
        <div class="reward-ways" data-mode="static">
          {{- range $way, $image := $reward.ways -}}
            {{- with T (printf "single.reward.%v" $way) -}}{{ $way = . }}{{- end -}}
            {{- if $image -}}
              <div>
                {{- dict "Src" $image "Alt" (printf "%v %v" $authorName $way) | partial "plugin/image.html" -}}
                <span>{{ $way }}</span>
              </div>
            {{- end -}}
          {{- end -}}
        </div>
      </div>
    {{- end -}}
    {{- /* 订阅 */ -}}
    {{- $rssURL := "" -}}
    {{- if .OutputFormats.Get "RSS" -}}
      {{- $rssURL = (.OutputFormats.Get "RSS").Permalink -}}
    {{- else -}}
      {{- $rssURL = "index.xml" | absURL -}}
    {{- end -}}
    <a href="{{ $rssURL }}" class="subscribe-button{{ if not $reward.enable }} subscribe-button--solo{{ end }}" target="_blank" rel="noopener noreferrer">
      <i class="fa-regular fa-bell"></i> 订阅
    </a>
  </div>
  {{- /* 版权 */ -}}
  <div class="post-license">
    本博客部分代码由 AI 辅助生成,内容采用&nbsp;{{ $params.license | safeHTML }}&nbsp;协议,转载请注明来自&nbsp;<a href="{{ .Permalink }}">{{ .Site.Title }}</a>
  </div>
  {{- /* 分享 */ -}}
  {{- $shareConfig := (partial "function/params.html").share | default dict -}}
  {{- if $shareConfig.enable -}}
  <div class="post-share">
    <div class="share-label">
      <i class="fa-regular fa-share-from-square"></i> 分享本文
    </div>
    <div class="share-button">
      <!-- Facebook -->
      {{- if $shareConfig.Facebook -}}
      <a href="javascript:void(0);" title="分享到 Facebook" data-sharer="facebook" data-url="{{ .Permalink }}">
        <i class="fa-brands fa-facebook-square"></i>
      </a>
      {{- end -}}
      <!-- Twitter (X)  -->
      {{- if $shareConfig.Twitter -}}
      <a href="javascript:void(0);" title="分享到 X" data-sharer="twitter" data-url="{{ .Permalink }}" data-title="{{ .Title }}">
        <i class="fa-brands fa-x-twitter"></i>
      </a>     
      {{- end -}} 
      <!-- 微信 -->
      {{- if $shareConfig.wechat -}}
      <span class="wechat-btn">
        <a href="javascript:void(0);" class="wechat" title="微信分享">
          <i class="fa-brands fa-weixin"></i>
        </a>
        <div class="qrcode-popup">
          <div id="wechat-qrcode" class="wechat-qrcode"></div>
          <div class="qrcode-text">扫码分享好友</div>
        </div>
      </span>  
      {{- end -}}
      <!-- 微博 -->
      {{- if $shareConfig.Weibo -}}
      <a href="javascript:void(0);" title="分享到 微博" data-sharer="weibo" data-url="{{ .Permalink }}" data-title="{{ .Title }}"{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}>
        <i class="fa-brands fa-weibo"></i>
      </a>      
      {{- end -}}
      <!-- 复制链接 -->
      {{- if $shareConfig.copy -}}
      <a href="javascript:void(0);" class="copy-btn" title="复制链接" data-url="{{ .Permalink }}" onclick="copyPageUrl(this);">
        <i class="fa-regular fa-copy"></i>
      </a> 
      {{- end -}}
    </div>
  </div>
  {{- end -}}
</div>

{{- /* 上下页导航 */ -}}
{{- $navigation := .Site.Params.navigation -}}
<div class="post-nav">
  {{- $pages := .Site.Store.Get "mainSectionPages" -}}
  {{- $prev := $pages.Prev . -}}
  {{- $next := $pages.Next . -}}
  {{- if $navigation.inSection -}}
    {{- $prev = .PrevInSection -}}
    {{- $next = .NextInSection -}}
  {{- end -}}
  {{- if $navigation.reverse -}}
    {{- $prev = $pages.Next . -}}
    {{- $next = $pages.Prev . -}}
  {{- end -}}
  {{- /* 上一页 */ -}}
  {{- with $prev -}}
    {{- $capitalizeTitles := .Param "capitalizeTitles" -}}
    <a href="{{ .RelPermalink }}" class="post-nav-item" rel="prev" title="{{ cond $capitalizeTitles (title .LinkTitle) .LinkTitle }}">
      {{- dict "Class" "fa-solid fa-angle-left" | partial "plugin/icon.html" -}}
      <span class="nav-title">{{ cond $capitalizeTitles (title .LinkTitle) .LinkTitle }}</span>
    </a>
  {{- end -}}
  {{- /* 下一页 */ -}}
  {{- with $next -}}
    {{- $capitalizeTitles := .Param "capitalizeTitles" -}}
    <a href="{{ .RelPermalink }}" class="post-nav-item" rel="next" title="{{ cond $capitalizeTitles (title .LinkTitle) .LinkTitle }}">
      <span class="nav-title">{{ cond $capitalizeTitles (title .LinkTitle) .LinkTitle }}</span>
      {{- dict "Class" "fa-solid fa-angle-right" | partial "plugin/icon.html" -}}
    </a>
  {{- end -}}
</div>

{{- /* 合集卡片 */ -}}
{{- if $params.collectionNavigation -}}
  {{- /* 获取当前文章所属的第一个合集 */ -}}
  {{- $collections := .GetTerms "collections" -}}
  {{- if $collections -}}
    {{- $collection := index $collections 0 -}}
    {{- $current := . -}}
    {{- $all := $collection.Pages.ByDate -}}
    {{- $total := len $all -}}
    {{- /* 找到当前文章索引 */ -}}
    {{- $currIdx := -1 -}}
    {{- range $idx, $p := $all -}}
      {{- if eq $p.Permalink $current.Permalink -}}
        {{- $currIdx = $idx -}}
        {{- break -}}
      {{- end -}}
    {{- end -}}
    {{- if ne $currIdx -1 -}}
      {{- $max := 6 -}}
      {{- $half := 3 -}}
      {{- $start := sub $currIdx $half -}}
      {{- $end := add $currIdx $half -}}
      {{- /* 边界修正 */ -}}
      {{- if lt $start 0 -}}
        {{- $end = add $end (sub 0 $start) -}}
        {{- $start = 0 -}}
      {{- end -}}
      {{- if ge $end $total -}}
        {{- $start = sub $start (sub $end (sub $total 1)) -}}
        {{- $end = sub $total 1 -}}
        {{- if lt $start 0 -}}{{- $start = 0 -}}{{- end -}}
      {{- end -}}
      {{- /* 收集范围内的其他文章 */ -}}
      {{- $others := slice -}}
      {{- range $i, $p := $all -}}
        {{- if and (ge $i $start) (le $i $end) (ne $p.Permalink $current.Permalink) -}}
          {{- $others = $others | append $p -}}
        {{- end -}}
      {{- end -}}
      {{- /* 如果不够 6 篇,从范围外邻近方向补充 */ -}}
      {{- if lt (len $others) $max -}}
        {{- $need := sub $max (len $others) -}}
        {{- /* 先向左补充 */ -}}
        {{- $leftIdx := sub $start 1 -}}
        {{- range $need -}}
          {{- if lt $leftIdx 0 -}}{{- break -}}{{- end -}}
          {{- $p := index $all $leftIdx -}}
          {{- if ne $p.Permalink $current.Permalink -}}
            {{- $others = slice $p | append $others -}}
          {{- end -}}
          {{- $leftIdx = sub $leftIdx 1 -}}
        {{- end -}}
        {{- /* 如果还不够,向右补充 */ -}}
        {{- if lt (len $others) $max -}}
          {{- $need2 := sub $max (len $others) -}}
          {{- $rightIdx := add $end 1 -}}
          {{- range $need2 -}}
            {{- if ge $rightIdx $total -}}{{- break -}}{{- end -}}
            {{- $p := index $all $rightIdx -}}
            {{- if ne $p.Permalink $current.Permalink -}}
              {{- $others = $others | append $p -}}
            {{- end -}}
            {{- $rightIdx = add $rightIdx 1 -}}
          {{- end -}}
        {{- end -}}
      {{- end -}}
      {{- /* 渲染合集卡片 */ -}}
      {{- if $others -}}
        <div class="custom-collection-card">
          <div class="custom-coll-title">
            <i class="fa-solid fa-layer-group"></i> {{ $collection.LinkTitle }}
          </div>
          <div class="custom-coll-list">
            {{- range $others -}}
              {{- $img := .Params.featuredimagepreview | default .Params.featuredimage -}}
              {{- if not $img -}}
                {{- with .Resources.GetMatch "featured-image-preview" -}}
                  {{- $img = .RelPermalink -}}
                {{- else with .Resources.GetMatch "featured-image" -}}
                  {{- $img = .RelPermalink -}}
                {{- end -}}
              {{- end -}}
              <a class="custom-coll-card" href="{{ .RelPermalink }}">
                <div class="coll-card-img" style="background-image: url('{{ $img | safeCSS }}');"></div>
                <div class="coll-card-info">
                  <div class="coll-card-date"><i class="fa-regular fa-calendar-alt"></i> {{ .Date | dateFormat "2006-01-02" }}</div>
                  <div class="coll-card-title">{{ .Title }}</div>
                </div>
              </a>
            {{- end -}}
          </div>
        </div>
      {{- end -}}
    {{- end -}}
  {{- end -}}
{{- end -}}

{{- /* 评论区标题 */ -}}
<div class="custom-comment-title">
  <i class="fa-regular fa-comments"></i> 留言交流
</div>

创建以下文件:

JavaScriptassets/js/custom.js
  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
(function() {

  // ========== 复制 + 二维码(仅文章页) ==========

  (function() {

    if (!document.querySelector('.page.single')) return;

    // 轻提示函数
    function showToast(msg) {
      const toast = document.createElement('div');
      toast.innerText = msg;
      toast.style.position = 'fixed';
      toast.style.top = '50%';
      toast.style.left = '50%';
      toast.style.transform = 'translate(-50%, -50%)';
      toast.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
      toast.style.color = '#fff';
      toast.style.padding = '10px 20px';
      toast.style.borderRadius = '30px';
      toast.style.fontSize = '14px';
      toast.style.fontWeight = '500';
      toast.style.zIndex = '9999';
      toast.style.whiteSpace = 'nowrap';
      toast.style.opacity = '0';
      toast.style.transition = 'opacity 0.2s';
      document.body.appendChild(toast);
      setTimeout(() => { toast.style.opacity = '1'; }, 10);
      setTimeout(() => {
        toast.style.opacity = '0';
        setTimeout(() => toast.remove(), 200);
      }, 1500);
    }

    // 全局复制函数
    window.copyPageUrl = function(btn) {
      var url = btn.getAttribute('data-url') || window.location.href;
      var text = document.title + '\n' + url;
      
      var textarea = document.createElement('textarea');
      textarea.value = text;
      textarea.style.position = 'fixed';
      textarea.style.top = '-9999px';
      textarea.style.left = '-9999px';
      document.body.appendChild(textarea);
      textarea.select();
      textarea.setSelectionRange(0, text.length); // 移动端兼容
      
      try {
        var success = document.execCommand('copy');
        if (success) {
          showToast('✅ 已复制');
        } else {
          // 失败时兜底
          window.prompt('请手动复制', text);
        }
      } catch (e) {
        window.prompt('请手动复制', text);
      }
      document.body.removeChild(textarea);
    };

    // 二维码生成(增强重试,避免无限循环)
    let qrRetryCount = 0;
    const MAX_QR_RETRY = 10;
    function initQRCode() {
      const qrcodeElem = document.getElementById('wechat-qrcode');
      if (!qrcodeElem) return;

      if (typeof QRCode !== 'undefined') {
        qrcodeElem.innerHTML = '';
        new QRCode(qrcodeElem, {
          text: window.location.href,
          width: 130,
          height: 130,
          colorDark: '#000000',
          colorLight: '#ffffff',
          correctLevel: QRCode.CorrectLevel.H
        });
        return;
      }

      // 如果库未加载,且未超过最大重试次数,则延迟重试
      if (qrRetryCount < MAX_QR_RETRY) {
        qrRetryCount++;
        setTimeout(initQRCode, 200);
      } else {
        console.warn('QRCode library failed to load after retries.');
      }
    }

    // 确保 DOM 就绪后执行,同时确保外部脚本(QRCode.js)已加载
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', initQRCode);
    } else {
      // 如果 DOM 早已就绪,但可能 QRCode.js 还未加载,同样启动重试
      initQRCode();
    }
  })();

})();  

修改主题配置:

TOMLconfig/_default/hugo.toml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[params.customPartials]
postFooterBefore = ["custom-single-footer.html"]

[params.page.share]
enable = true
wechat = true
copy = true

[params.page.library.js]
QRCode = "https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"

创建以下文件:

SCSSassets/css/_custom.scss
  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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 文章页 =========

.single {
  // 隐藏文章页脚
  .post-footer {
    display: none;
  }

  .custom-post-footer {
    position: relative; 
    text-align: center;
    border-radius: 10px;
    transition: all 0.3s;
    background-color: var(--c-postinfo-bg);
    border: 1px solid var(--c-postinfo-border);
    margin-block: calc(var(--c-space-12) * 3) var(--c-space-4);
    padding: var(--c-space-12) var(--c-space-8) var(--c-space-6);
    @include media('print') { display: none; }

    .avatar-frame {
      top: -40px; 
      left: 50%;
      z-index: 10;
      width: 80px;
      height: 80px;
      display: flex;
      overflow: hidden;
      position: absolute;
      border-radius: 50%;
      align-items: center;
      box-sizing: border-box;
      justify-content: center;
      font-size: var(--c-font-xs);
      transform: translateX(-50%);
      box-shadow: var(--c-avatar-shadow);
      background-color: var(--c-avatar-bg);
      border: 2px solid var(--c-avatar-border);
      transition: transform 0.3s ease, box-shadow 0.3s ease;

      &:hover {
        transform: translateX(-50%) scale(1.05);
        box-shadow: var(--c-avatar-shadow-hover);
      }

      &::after {
        content: "关于博主";
        top: 0;
        left: 0;
        opacity: 0;
        width: 100%;
        height: 100%;
        display: flex;
        font-weight: 500;
        color: #ffffff; 
        position: absolute;
        border-radius: 50%;
        align-items: center;
        pointer-events: none;
        justify-content: center;          
        transition: opacity 0.3s ease;
        background-color: rgba(0, 0, 0, 0.6);
      }

      &:hover::after {
        opacity: 1;
      }

      img.avatar, 
      .avatar-placeholder {
        width: 100%;
        height: 100%;
        display: block;
        object-fit: cover;
        border-radius: 50%;
      }

      .avatar-placeholder {
        background-color: var(--c-avatar-bg);
      }
    }

    .author-info {
      .author-name {
        font-weight: 600;
        font-size: var(--c-font-l); 
      }

      .author-bio {
        color: var(--c-meta);
        font-size: var(--c-font-xs);
      }
    }

    .action-buttons {
      display: flex;
      flex-wrap: wrap;
      position: relative;
      align-items: center;
      gap: var(--c-space-4);
      justify-content: center;
      font-size: var(--c-font-s);
      margin-block: var(--c-space-2);

      .post-reward {
        padding: 0;
        position: relative;
        text-align: center;
        align-items: center;
        display: inline-flex;

        &:hover .reward-ways[data-mode="static"] {
          opacity: 1;
          visibility: visible;
          transform: translateX(-50%) translateY(0);
        }
      }

      .subscribe-button,
      .reward-button {
        border: none;
        cursor: pointer;
        color: #ffffff;
        font-weight: 500;  
        line-height: 1.2;
        border-radius: 10px;
        align-items: center;
        transition: all 0.3s;
        display: inline-flex;
        text-decoration: none;
        gap: var(--c-space-1);
        box-sizing: border-box;
        justify-content: center;
        padding: calc(var(--c-space-1) * 3);

        &:hover {
          transform: translateY(-1px);
        }
      }      

      .reward-button {
        background-color: var(--c-reward-btn-bg);

        &:hover {
          background-color: var(--c-reward-btn-hover);
        }
      }

      .subscribe-button {
        background-color: var(--c-subscribe-btn-bg);

        &:hover {
          background-color: var(--c-subscribe-btn-hover); 
        }
      }   

      .subscribe-button--solo {
        min-width: 90px;
      } 

      .reward-ways[data-mode="static"] {
        left: 50%;
        opacity: 0;
        z-index: 20;
        bottom: 100%;
        display: grid;
        visibility: hidden;
        position: absolute;
        border-radius: 12px;
        gap: var(--c-space-4);
        box-sizing: border-box;
        justify-content: center;
        transition: all 0.3s ease;
        box-shadow: var(--c-card-shadow);
        background-color: var(--c-card-bg);
        margin-bottom: calc(var(--c-space-1) * 3);
        transform: translateX(-50%) translateY(12px);
        grid-template-columns: repeat(2, minmax(130px, auto));
        padding: var(--c-space-6) var(--c-space-6) var(--c-space-4);
        @include phone { grid-template-columns: 1fr; width: 200px; }   

        // 单个二维码时,改为单列居中
        &:has(> div:only-child) {
          grid-template-columns: 1fr;
          width: auto;
          min-width: 180px;
        }

        &::after {
          content: '';
          position: absolute;
          top: 100%;
          left: 50%;
          border-style: solid;
          border-width: 6px 6px 0;
          transform: translateX(-50%);
          border-color: var(--c-card-bg) transparent transparent;
        }

        div {
          width: 100%;
          display: flex;
          align-items: center;
          gap: var(--c-space-2);
          flex-direction: column;
        }

        img {
          width: 130px;
          height: 130px;
          display: block;
          border-radius: 6px;
          object-fit: contain;
          box-sizing: border-box;
          background-color: #fff;
        }

        span {
          display: block;
          line-height: 1.3;
          text-align: center;
          color: var(--c-meta);
          font-size: var(--c-font-s);
        }
      }            
    }

    .post-license {
      line-height: 1.6;
      color: var(--c-meta);   
      font-size: var(--c-font-xs);   
      margin-block: var(--c-space-2);

      a {
        color: var(--c-link);
        text-decoration: none;

        &:hover {
          text-decoration: underline;
          color: var(--c-link-hover);
        }
      }
    }

    .post-share {
      border-top: 1px solid var(--c-card-border);
      
      .share-label {
        text-align: center;   
        letter-spacing: 1px;
        color: var(--c-meta);
        text-transform: uppercase;
        font-size: var(--c-font-xs);
        margin-block: var(--c-space-2);
      }   
      
      .share-button {
        display: flex;
        flex-wrap: wrap;
        gap: var(--c-space-2);
        justify-content: center;
        margin-block: var(--c-space-2);
      }      

      a {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        align-items: center;
        color: var(--c-meta);
        display: inline-flex;
        transition: all 0.3s;
        justify-content: center;
        background-color: var(--c-meta-bg);

        &:hover {
          color: var(--c-meta-hover);
          transform: translateY(-2px);
          background-color: var(--c-meta-bg-hover);
        }
      }

      a[data-sharer="twitter"] {
        color: #1da1f2;

        &:hover {
          color: #fff;
          background-color: #1da1f2;
        }
      }

      a[data-sharer="facebook"] {
        color: #1877f2;

        &:hover {
          color: #fff;
          background-color: #1877f2;
        }
      }

      a[data-sharer="weibo"] {
        color: #e6162d;

        &:hover {
          color: #fff;
          background-color: #e6162d;
        }
      }

      .wechat {
        color: #2baf2b;

        &:hover {
          color: #fff;
          transform: translateY(-2px);
          background-color: #2baf2b;  
        }
      }

      .wechat-btn {
        position: relative;
        display: inline-flex;
        
        &:hover .qrcode-popup {
          opacity: 1;
          visibility: visible;
          transform: translateX(-50%) translateY(0);
        }
      }

      .qrcode-popup {
        left: 50%;
        opacity: 0;
        z-index: 20;
        bottom: 100%; 
        position: absolute;
        visibility: hidden;
        text-align: center;
        border-radius: 10px;
        transition: all 0.3s ease;
        box-shadow: var(--c-card-shadow);
        background-color: var(--c-card-bg);
        margin-bottom: calc(var(--c-space-1) * 3);
        transform: translateX(-50%) translateY(12px);
        padding: var(--c-space-6) var(--c-space-6) var(--c-space-4); 
        
        &::after {
          top: 100%;
          left: 50%;
          content: '';
          position: absolute;
          border-style: solid;
          border-width: 6px 6px 0;
          transform: translateX(-50%);
          border-color: var(--c-card-bg) transparent transparent;
        }

        .wechat-qrcode {
          width: 130px;
          height: 130px;
          border-radius: 6px;
          display: inline-block;
          background-color: #fff;
          padding: calc(var(--c-space-6) / 10);
        }

        .qrcode-text {
          color: var(--c-meta);
          font-size: var(--c-font-s);
        }        
      }
    }
  }

  .post-nav {
    display: flex;
    border-radius: 10px;
    gap: var(--c-space-4);
    padding: var(--c-space-4);
    transition: box-shadow 0.2s;
    justify-content: space-between;
    background-color: var(--c-postinfo-bg);
    margin-bottom: calc(var(--c-space-8) * 2);
    border: 1px solid var(--c-postinfo-border);
    @include media('print') { display: none !important; }
    @include phone { flex-direction: column; gap: var(--c-space-2); padding: var(--c-space-2); }

    .post-nav-item {
      flex: 1;
      min-width: 0;
      display: flex;
      font-weight: 600;
      align-items: center;
      text-decoration: none;
      gap: var(--c-space-2);
      font-size: var(--c-font-m);
      transition: all 0.3s ease-out;

      &:hover {
        transform: translateX(0) !important;
      }  

      i, svg {
        flex-shrink: 0;
      }           
      
      .nav-title {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }

      &[rel='prev'] {
        justify-content: flex-start;

        .nav-title {
          text-align: left;
        }        
      }

      &[rel='next'] {
        justify-content: flex-end;

        .nav-title {
          text-align: right;
        }            
      }
    }
  }

  .custom-collection-card {
    margin-block: var(--c-space-8);
    @include media('print') { display: none !important; }

    .custom-coll-title {
      display: flex;
      font-weight: 700;
      align-items: center;
      gap: var(--c-space-2);
      color: var(--c-meta-alt);
      font-size: var(--c-font-xxl);
      margin-block: var(--c-space-4);
    }

    .custom-coll-list {
      display: grid;
      gap: var(--c-space-2);
      margin-block: var(--c-space-8);
      grid-template-columns: repeat(3, 1fr);
      @include phone { grid-template-columns: 1fr; }
      @include pad { grid-template-columns: repeat(2, 1fr); }
    }

    .custom-coll-card {
      position: relative;
      overflow: hidden;
      border-radius: 6px;
      text-decoration: none;
      transition: box-shadow 0.2s;
      box-shadow: var(--c-card-shadow); 
      background-color: var(--c-card-bg);

      &:hover {
        box-shadow: var(--c-card-shadow-hover);

        .coll-card-img {
          transform: scale(1.1);
        }      

        .coll-card-img::after {
          background: rgba(0, 0, 0, 0.75);
        }        
      }

    }

    .coll-card-img {
      width: 100%;
      aspect-ratio: 16 / 9;
      background-size: cover;
      background-position: center;
      background-color: var(--c-meta-bg);
      transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.4, 1.1);
      @include phone { aspect-ratio: 3 / 1; background-position: center 100%; }
      @include pad { aspect-ratio: 2 / 1; background-position: center 100%; }

      &::after {
        top: 0;
        left: 0;
        width: 100%;
        content: '';
        height: 100%;        
        position: absolute;
        pointer-events: none;
        transition: background 0.2s;
        background: rgba(0, 0, 0, 0.5);
      }
    }

    .coll-card-info {
      left: 0;
      right: 0;     
      bottom: 6px;
      color: #fff;
      position: absolute;
      text-align: center;
      font-size: var(--c-font-xs);
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
      @include pad { bottom: 4px; }

      .coll-card-date {
        opacity: 0.9;
      }

      .coll-card-title {
        font-weight: 500;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }      
    }
  }

  .custom-comment-title {
    display: flex;
    font-weight: 700;
    align-items: center;
    gap: var(--c-space-2);
    color: var(--c-meta-alt);
    font-size: var(--c-font-xxl);
    margin-top: var(--c-space-12);
    @include media('print') { display: none !important; }
  }
}

右下角合集控件

FixIt 2026.5.1 | 更改

[params.page] collectionList 控制,点击弹出当前文章合集列表。

创建以下文件:

HTMLlayouts/_partials/custom-widget-collection.html
 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
{{- /* 自定义块来源:FixIt/layouts/_partials/widgets.html */ -}}
{{- /* 自定义块来源:FixIt/layouts/posts/single.html */ -}}

{{- /* 合集按钮与右侧抽屉 - 仅文章页且属于合集时显示 */ -}}
{{- if and .IsPage .Params.collections -}}
  {{- $params := partial "function/params.html" -}}
  {{- if $params.collectionList -}}
    {{- /* 调用极简合集列表 */ -}}
    {{- $collectionListHTML := partial "custom-collection-list.html" . -}}
    {{- if and $collectionListHTML (ne $collectionListHTML "") -}}
      {{- /* 获取第一个合集名称 */ -}}
      {{- $collectionName := "" -}}
      {{- $collectionTerms := .GetTerms "collections" -}}
      {{- if $collectionTerms -}}
        {{- $collectionName = (index $collectionTerms 0).LinkTitle -}}
      {{- end -}}
      {{- /* 按钮模板 */ -}}
      <template id="collection-button-template">
        <div class="fixed-button collection-drawer-button" role="button" aria-label="合集">
          {{- dict "Class" "fa-solid fa-layer-group" | partial "plugin/icon.html" -}}
        </div>
      </template>
      {{- /* 合集对话框 */ -}}
      <dialog id="collection-dialog" aria-labelledby="collection-dialog-title" role="dialog">
        <div class="collection-dialog">
          <h2 class="collection-dialog-title" id="collection-dialog-title">合集 · {{ $collectionName }}</h2>
          <div class="collection-dialog-content" id="collection-dialog-content">
            {{- $collectionListHTML | safeHTML -}}
          </div>
        </div>
      </dialog>
    {{- end -}}
  {{- end -}}
{{- end -}}

创建以下文件:

HTMLlayouts/_partials/custom-collection-list.html
 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
{{- /* 自定义块来源:FixIt/layouts/_partials/single/collection-list.html */ -}}

{{- $params := partial "function/params.html" -}}

{{- if .Params.collections | and $params.collectionList -}}
  {{- $collectionTerms := .GetTerms "collections" -}}
  {{- range $collectionTerms -}}
    {{- $pages := (where .Pages "Params.Weight" "!=" nil) | append (where .Pages "Params.Weight" "eq" nil).ByDate -}}

    {{- /* ======================== 修改点 1:开始 ======================== */ -}}
    {{- /* 极简合集列表:移除折叠结构和底部导航,仅保留文章标题链接 */ -}}
    <ul class="collection-drawer-list">
      {{- range $pages -}}
        {{- $capitalizeTitles := .Param "capitalizeTitles" -}}
        {{- $title := .Params.shortTitle | default .LinkTitle -}}
        {{- $title = cond $capitalizeTitles (title $title) $title -}}
        <li>
          {{- if $.Eq . -}}
            <a class="active" href="{{ .RelPermalink }}">{{ $title }}</a>
          {{- else -}}
            <a href="{{ .RelPermalink }}">{{ $title }}</a>
          {{- end -}}
        </li>
      {{- end -}}
    </ul>
    {{- /* ======================== 修改点 1:结束 ======================== */ -}}
    
  {{- end -}}
{{- end -}}

创建以下文件:

JavaScriptassets/js/custom.js
 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
(function() {

  // ========== 合集抽屉(仅文章页且存在对话框) ==========

  (function() {
    if (!document.getElementById('collection-dialog')) return;

    function initCollectionWidget() {
      const container = document.querySelector('.fixed-buttons');
      if (!container) return;
      if (container.querySelector('.collection-drawer-button')) return;

      const template = document.getElementById('collection-button-template');
      if (!template) return;
      const button = template.content.firstElementChild.cloneNode(true);

      const tocBtn = container.querySelector('.toc-drawer-button');
      const commentBtn = container.querySelector('.view-comments');

      if (tocBtn && tocBtn.nextSibling) {
        container.insertBefore(button, tocBtn.nextSibling);
      } else if (commentBtn) {
        container.insertBefore(button, commentBtn);
      } else {
        container.appendChild(button);
      }

      const dialog = document.getElementById('collection-dialog');
      if (!dialog) return;

      button.addEventListener('click', (e) => {
        e.stopPropagation();
        dialog.showModal();
      });

      dialog.addEventListener('click', (e) => {
        const rect = dialog.getBoundingClientRect();
        const isInDialog = (rect.top <= e.clientY && e.clientY <= rect.top + rect.height &&
          rect.left <= e.clientX && e.clientX <= rect.left + rect.width);
        if (!isInDialog) dialog.close();
      });
    }

    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', initCollectionWidget);
    } else {
      initCollectionWidget();
    }
  })();

})();  

修改主题配置:

TOMLconfig/_default/hugo.toml
1
2
3
4
5
[params.customPartials]
widgets = ["custom-widget-collection.html"]

[params.page]
collectionList = true

创建以下文件:

SCSSassets/css/_custom.scss
  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
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 按钮控件 =========

// 合集按钮:取消注释即只显示在移动端
/*.collection-drawer-button {
  @include media('md', 'up') { display: none !important; }
}*/

// 合集列表
#collection-dialog {
  opacity: 0;
  border: none;
  height: 100dvh;
  max-width: 100%;
  margin-right: 0;
  max-height: 100%; 
  translate: 100vw 0;
  width: MIN(calc(100% - 4rem), 460px);
  background-color: var(--c-collection-bg);
  border-left: 1px solid var(--c-collection-border);
  transition: display 0.2s allow-discrete, overlay 0.2s allow-discrete, translate 0.2s, opacity 0.2s 0.4s;

  a:focus {
    outline: none !important;
    box-shadow: none !important;
  }
  
  .collection-dialog {
    max-width: 100%;
    margin-inline: var(--c-space-6);

    .collection-dialog-title {
      font-weight: bold;
      line-height: 1.7;
      font-size: var(--c-font-xxl);
      margin-block: var(--c-space-4);
      text-transform: none !important;
    }

    .collection-dialog-content {
      line-height: 1.6;
      margin-block: var(--c-space-4);

      nav {
        overflow: auto;
        max-height: calc(100dvh - 5rem);
      }

      ul {
        margin: 0;
        list-style: none;
        text-indent: -0.8rem;
        padding-left: var(--c-space-4);

        a:first-child::before {
          bottom: 2px;
          content: '|';
          position: relative;
          font-weight: bolder;
          color: var(--c-link);
          margin-right: var(--c-space-2);
        }
      }

      a.active {
        font-weight: bold;
        color: var(--c-link);
      }

      a.active::before {
        color: var(--c-link-hover) !important;
      }
    }
  }

  &::backdrop {
    opacity: 0;
    backdrop-filter: blur(2px);
    background-color: rgba(0, 0, 0, 0.25);
    transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete, opacity 0.2s 0.4s;
  }

  &[open], 
  &[open]::backdrop {
    opacity: 1;
    transition: display 0.2s allow-discrete, overlay 0.2s allow-discrete, translate 0.2s, opacity 0.2s;
  }

  &[open] {
    translate: 0 0;
  }

  @starting-style {
    &[open], 
    &[open]::backdrop {
      opacity: 0;
    }

    &[open] {
      translate: 100vw 0;
    }
  }
}

html:has(#collection-dialog[open]) {
  overflow: hidden;
}

代码块语言显示

FixIt 2026.5.1 | 更改

硬编码语言名称,增加 code-lang-name 占位容器,不依赖 CSS 伪元素。

创建以下文件:

HTMLlayouts/_partials/function/code-header.html
  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
{{- /* 覆盖来源:FixIt/layouts/_partials/function/code-header.html */ -}}

{{- /* Code header for classic mode code blocks */ -}}
{{- $config := .Config -}}
{{- $wrapper := .Wrapper -}}
{{- $lang := cond (transform.CanHighlight .Type) (lower .Type) "fallback" -}}
{{- $name := $config.name -}}
{{- $lineNosBtn := "" -}}
{{- $lineWrapBtn := "" -}}
{{- $editBtn := "" -}}
{{- $copyBtn := "" -}}
{{- $downloadBtn := "" -}}
{{- $fullscreenBtn := "" -}}
{{- $foldIcon := dict "Class" "arrow fa-solid fa-chevron-down" | partial "plugin/icon.html" -}}

{{- /* ======================== 修改点 1:开始 ======================== */ -}}
{{- /* 使用硬编码映射将常见语言标识符转换为可读名称,未映射的回退为原始标识符并首字母大写 */ -}}
{{- /* 代码语言来源:FixIt/assets/css/_maps/_code-type.scss */ -}}
{{- $codeTypes := .Site.Data.code_types -}}
{{- $langMap := dict
  "bash" "Bash"
  "bat" "Batchfile"
  "batch" "Batchfile"
  "c" "C"
  "clojure" "Clojure"
  "cmake" "CMake"
  "cmd" "CMD"
  "cpp" "C++"
  "csharp" "C#"
  "css" "CSS"
  "dart" "Dart"
  "diff" "Diff"
  "dockercompose" "Docker Compose"
  "dockerfile" "Dockerfile"
  "dockerignore" "Docker Ignore"
  "elixir" "Elixir"
  "erlang" "Erlang"
  "gitignore" "Git Ignore"
  "go" "Go"
  "gradle" "Gradle"
  "graphql" "GraphQL"
  "handlebars" "Handlebars"
  "haskell" "Haskell"
  "html" "HTML"
  "ini" "INI"
  "java" "Java"
  "js" "JavaScript"
  "json" "JSON"
  "javascript" "JavaScript"
  "jsx" "React JSX"
  "kotlin" "Kotlin"
  "lua" "Lua"
  "makefile" "Makefile"
  "markdown" "Markdown"
  "matlab" "MATLAB"
  "nginx" "Nginx"
  "ocaml" "OCaml"
  "perl" "Perl"
  "php" "PHP"
  "powershell" "PowerShell"
  "properties" "Properties"
  "protobuf" "Protocol Buffer"
  "python" "Python"
  "r" "R"
  "ruby" "Ruby"
  "rust" "Rust"
  "sass" "Sass"
  "scala" "Scala"
  "scss" "SCSS"
  "shell" "Shell"
  "sql" "SQL"
  "svelte" "Svelte"
  "swift" "Swift"
  "text" "Plaintext"
  "toml" "TOML"
  "tsx" "React TSX"
  "typescript" "TypeScript"
  "vb" "VBA"
  "vim" "Vim Script"
  "vue" "Vue"
  "xml" "XML"
  "yaml" "YAML"
  "zsh" "Zsh"
-}}
{{- $langKey := $lang | lower -}}
{{- $readableLang := index $langMap $langKey -}}
{{- if not $readableLang -}}
  {{- $readableLang = $lang | title -}}
{{- end -}}
{{- $langSpan := printf `<span class="code-lang-name">%s</span>` $readableLang -}}
{{- $titleEl := printf `<span class="code-title">%s%s</span>` $foldIcon $langSpan -}}
{{- /* ======================== 修改点 1:结束 ======================== */ -}}

{{- $ellipsisBtn := printf `<span class="ellipses-btn" aria-label="Show more options" role="button">%s</span>` (dict "Class" "fa-solid fa-ellipsis-h" | partial "plugin/icon.html") -}}

{{- if $config.title -}}
  {{- $titleEl = printf `<span class="code-title">%s%s<span class="title-inner">%s</span></span>` $foldIcon $langSpan $config.title -}}
{{- end -}}
{{- if $config.linenostoggler -}}
  {{- $lineNosIcon := dict "Class" "fa-solid fa-list-ol" | partial "plugin/icon.html" -}}
  {{- $lineNosBtn = printf `<span class="action-btn line-nos-btn" aria-label="%s" role="button" title="%s" data-ct-tooltip>%s</span>` (T "assets.toggleLineNumbers") (T "assets.toggleLineNumbers") $lineNosIcon -}}
{{- end -}}
{{- if $config.linewraptoggler -}}
  {{- $lineWrapIcon := dict "Class" "fa-solid fa-right-left" | partial "plugin/icon.html" -}}
  {{- $lineWrapBtn = printf `<span class="action-btn line-wrap-btn" aria-label="%s" role="button" title="%s" data-ct-tooltip>%s</span>` (T "assets.toggleLineWrap") (T "assets.toggleLineWrap") $lineWrapIcon -}}
{{- end -}}
{{- if $config.editable -}}
  {{- $editIcon := dict "Class" "fa-solid fa-pen-to-square" | partial "plugin/icon.html" -}}
  {{- $editBtn = printf `<span class="action-btn edit-btn" aria-label="%s" role="button" title="%s" data-ct-tooltip>%s</span>` (T "assets.toggleCodeEditable") (T "assets.toggleCodeEditable") $editIcon -}}
{{- end -}}
{{- if $config.copyable -}}
  {{- $copyIcon := dict "Class" "fa-regular fa-clone" | partial "plugin/icon.html" -}}
  {{- $copyBtn = printf `<span class="action-btn copy-btn" aria-label="%s" role="button" title="%s" data-copied-text="%s" data-ct-tooltip>%s</span>` (T "assets.copyToClipboard") (T "assets.copyToClipboard") (T "assets.copiedText") $copyIcon -}}
{{- end -}}
{{- if $config.downloadable -}}
  {{- $downloadIcon := dict "Class" "fa-solid fa-download" | partial "plugin/icon.html" -}}
  {{- $downloadBtn = printf `<span class="action-btn download-btn" aria-label="%s" role="button" title="%s" data-ct-tooltip>%s</span>` (T "assets.downloadCode") (T "assets.downloadCode") $downloadIcon -}}
{{- end -}}
{{- if $config.fullscreen -}}
  {{- $fullscreenIcon := dict "Class" "fa-solid fa-expand" | partial "plugin/icon.html" -}}
  {{- $fullscreenBtn = printf `<span class="action-btn fullscreen-btn" aria-label="%s" role="button" title="%s" data-ct-tooltip>%s</span>` (T "assets.toggleCodeFullscreen") (T "assets.toggleCodeFullscreen") $fullscreenIcon -}}
{{- end -}}
{{- with $config.name -}}
  {{- $titleEl = replace $titleEl `<span class="code-title">` (printf `<span class="code-title" data-name="%s">` .) -}}
{{- end -}}
{{- $codeHeader := printf `<div class="code-header language-%s">%s%s%s%s%s%s%s%s</div>` $lang $titleEl $ellipsisBtn $lineNosBtn $lineWrapBtn $editBtn $copyBtn $downloadBtn $fullscreenBtn -}}
{{- $wrapper = replaceRE `(<div class="code-wrapper">)` (printf "%s$1" $codeHeader) $wrapper -}}

{{- return $wrapper -}}

创建以下文件:

SCSSassets/css/_custom.scss
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
.single {
  .content {
    .highlight {
      .code-title {
        &::after {
          content: none !important;
        }
      }
    } 
  }
}      

导航栏滚动标题

FixIt 2026.5.6 | 更改

滚动时替换导航栏站点名称为文章标题,移动端可选禁用。

创建以下文件:

JavaScriptassets/js/custom.js
 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
(function() {

  // ========== 滚动标题(仅文章页) ==========

  (function() {
    if (!document.querySelector('.page.single')) return;

    // 移动端可选禁用(默认注释)
    // if (window.matchMedia('(max-width: 767px)').matches) return;

    const desktopHeader = document.getElementById('header-desktop');
    const mobileHeader = document.getElementById('header-mobile');
    const titleSpan = document.querySelector('.single-title span');
    if (!titleSpan || !desktopHeader) return;

    const articleTitle = titleSpan.innerText.trim();
    const THRESHOLD = 100;

    let desktopOriginal = null;
    let mobileOriginal = null;

    function setScrolled(header, scrolled) {
      const titleDiv = header.querySelector('.header-title');
      if (titleDiv) {
        if (scrolled) titleDiv.classList.add('scrolled');
        else titleDiv.classList.remove('scrolled');
      }
    }

    function replaceTitle(header, isDesktop) {
      const textSpan = header.querySelector('.header-title-text');
      if (!textSpan) return;
      if (isDesktop && desktopOriginal === null) desktopOriginal = textSpan.innerText;
      else if (!isDesktop && mobileOriginal === null) mobileOriginal = textSpan.innerText;
      textSpan.innerText = articleTitle;
      setScrolled(header, true);
    }

    function restoreTitle(header, isDesktop) {
      const textSpan = header.querySelector('.header-title-text');
      if (!textSpan) return;
      if (isDesktop && desktopOriginal !== null) {
        textSpan.innerText = desktopOriginal;
        desktopOriginal = null;
      } else if (!isDesktop && mobileOriginal !== null) {
        textSpan.innerText = mobileOriginal;
        mobileOriginal = null;
      }
      setScrolled(header, false);
    }

    let ticking = false;
    function update() {
      const show = window.scrollY > THRESHOLD;
      if (show) {
        if (desktopOriginal === null) replaceTitle(desktopHeader, true);
        if (mobileHeader && mobileOriginal === null) replaceTitle(mobileHeader, false);
      } else {
        if (desktopOriginal !== null) restoreTitle(desktopHeader, true);
        if (mobileHeader && mobileOriginal !== null) restoreTitle(mobileHeader, false);
      }
    }

    window.addEventListener('scroll', () => {
      if (!ticking) {
        requestAnimationFrame(() => { update(); ticking = false; });
        ticking = true;
      }
    });
    update();
  })();

})();   

创建以下文件:

SCSSassets/css/_custom.scss
 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
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 导航栏 =========

header {
  box-shadow: var(--c-header-shadow);
  -webkit-backdrop-filter: blur(12px);
  background-color: var(--c-header-bg);
  border-bottom: 1px solid var(--c-header-border);
  backdrop-filter: blur(20px) brightness(1.02) saturate(1.1);
}

.header-wrapper {
   padding: 0 var(--c-space-8) !important;
   @include phone { padding: 0 var(--c-space-4) !important; }
}

.header-title {
  .header-title-text {
    margin-inline: var(--c-space-2);
  }

  &.scrolled {
    .header-title-text {
      opacity: 0.9;
      font-size: var(--c-font-xl);
      text-shadow: 0 0 2px rgba(255, 255, 255, 0.3);
      transition: text-shadow 0.2s ease, opacity 0.2s ease;
    }
  }
}  

脚注悬浮提示

FixIt 2026.5.19 | 更改

动态添加“参考资料”标题,优化脚注内容显示(为链接添加 🔗 图标),自定义脚注悬浮提示(支持链接点击、移除原生 title 提示),调整提示框位置与样式。

创建以下文件:

JavaScriptassets/js/custom.js
  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
(function() {

  // ========== 脚注(仅文章页) ==========

  (function() {
    if (!document.querySelector('.page.single')) return;

    // 为脚注区域添加“参考资料”标题
    function addFootnotesTitle() {
      const footnotesDiv = document.querySelector('.footnotes[role="doc-endnotes"]');
      if (!footnotesDiv) return;
      if (footnotesDiv.querySelector('.footnotes-title')) return;
      
      const title = document.createElement('h2');
      title.className = 'footnotes-title';
      title.textContent = '参考资料';
      footnotesDiv.insertBefore(title, footnotesDiv.firstChild);
    }

    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', addFootnotesTitle);
    } else {
      addFootnotesTitle();
    }
  })();

  (function() {
    if (!document.querySelector('.page.single')) return;

    let currentTip = null;
    let hideTimer = null;

    // 为脚注内容中的链接添加 🔗 图标(不重复添加)
    function addLinkIcon(html) {
      const div = document.createElement('div');
      div.innerHTML = html;
      const links = div.querySelectorAll('a');
      links.forEach(link => {
        if (!link.innerHTML.includes('🔗')) {
          link.innerHTML = link.innerHTML + ' 🔗';
        }
      });
      // 移除返回链接(↩)
      const backLink = div.querySelector('.footnote-return, a[href^="#fnref:"]');
      if (backLink) backLink.remove();
      return div.innerHTML;
    }

    function cleanContent(html) {
      return addLinkIcon(html);
    }

    // 清除脚注链接及其父元素上所有可能导致原生提示的属性
    function scrubAttributes(el) {
      const attrs = ['title', 'data-ct-title', 'data-ct-original-title', 'data-original-title', 'tooltip'];
      // 清理自身
      attrs.forEach(attr => el.removeAttribute(attr));
      // 清理父级(通常是 <sup> 或 <span>)
      if (el.parentElement) {
        attrs.forEach(attr => el.parentElement.removeAttribute(attr));
      }
      // 清理再上一级(如果有必要,例如 <sup> 外面可能还有 <span>)
      if (el.parentElement && el.parentElement.parentElement) {
        attrs.forEach(attr => el.parentElement.parentElement.removeAttribute(attr));
      }
    }

    function showTooltip(anchor) {
      const href = anchor.getAttribute('href');
      if (!href || href[0] !== '#') return;
      const target = document.getElementById(href.slice(1));
      if (!target) return;

      if (currentTip) currentTip.remove();
      if (hideTimer) clearTimeout(hideTimer);

      const tip = document.createElement('div');
      tip.className = 'custom-fn-tooltip';
      tip.innerHTML = cleanContent(target.innerHTML);
      document.body.appendChild(tip);

      const aRect = anchor.getBoundingClientRect();
      const tRect = tip.getBoundingClientRect();
      const sx = window.scrollX, sy = window.scrollY;

      let left = aRect.left + sx - 14;
      let top = aRect.bottom + sy + 10;
      left = Math.min(Math.max(left, sx + 5), sx + window.innerWidth - tRect.width - 5);
      if (top + tRect.height > sy + window.innerHeight - 10) {
        top = aRect.top + sy - tRect.height - 6;
      }
      tip.style.position = 'absolute';
      tip.style.top = top + 'px';
      tip.style.left = left + 'px';

      currentTip = tip;

      tip.addEventListener('mouseenter', () => {
        if (hideTimer) clearTimeout(hideTimer);
      });
      tip.addEventListener('mouseleave', () => {
        hideTimer = setTimeout(() => {
          if (currentTip) {
            currentTip.remove();
            currentTip = null;
          }
        }, 800);
      });
    }

    function hideTooltip() {
      if (hideTimer) clearTimeout(hideTimer);
      hideTimer = setTimeout(() => {
        if (currentTip) {
          currentTip.remove();
          currentTip = null;
        }
      }, 800);
    }

    function preventJump(anchor) {
      anchor.addEventListener('click', (e) => e.preventDefault());
    }

    function init() {
      const refs = document.querySelectorAll('.footnote-ref, a[href^="#fn:"]');
      refs.forEach(el => {
        scrubAttributes(el);
        preventJump(el);
        el.addEventListener('mouseenter', () => showTooltip(el));
        el.addEventListener('mouseleave', hideTooltip);
      });
    }

    // 实时监控,防止动态添加的脚注带 title
    const observer = new MutationObserver(() => {
      const refs = document.querySelectorAll('.footnote-ref, a[href^="#fn:"]');
      refs.forEach(scrubAttributes);
    });
    observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['title'] });

    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', init);
    } else {
      init();
    }
  })();

})();

修改主题配置:

TOMLconfig/_default/hugo.toml
1
2
[params]
tooltip = false

创建以下文件:

SCSSassets/css/_custom.scss
 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
// 全局变量与样式参见《全局 - 样式覆盖》

// ========= 文章页 =========

.single {
  .content {  
    .footnotes {
      margin-block: var(--c-space-10);

      .footnotes-title {
        color: var(--c-meta-alt);
        margin-block: var(--c-space-2) calc(var(--c-space-1) * 3);
      }      
    }
  }
}

.custom-fn-tooltip {
  z-index: 10000;
  line-height: 1.5;
  max-width: 260px;
  border-radius: 6px;
  position: absolute;
  pointer-events: auto;
  word-wrap: break-word;
  color: var(--tooltip-color);
  font-size: var(--c-font-xs);
  background: var(--tooltip-bg);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
  padding-inline: calc(var(--c-space-1) * 3);
  
  a {
    text-decoration: none;

    &:hover {
      color: var(--c-link-hover);
      text-decoration: underline;
    }
  }
}  
留言交流