
Butterfly重装日记
Hexo 实现实时预览编辑
点击下拉查看具体内容
参考自:Hexo 实现实时预览编辑 | 木头的博客 (mutoe.com)
主要在项目目录下安装 hexo-browsersync
插件
1 | npm install hexo-browsersync --save |
然后运行 hexo server, 看到以下内容就说明启动成功啦.【针对_config.Butterfly.yml需要重启hexo s】
1 | [Browsersync] Access URLs: |
解决hexo引入图床,手机和web不显示图片的问题
点击下拉查看具体内容
这里以Butterfly主题为例
在butterfly\layout\includes\head.pug中【其中加号为需要添加的】
1 | meta(name="author" content=pageAuthor) |
背景音乐添加
点击下拉查看具体内容
参考自hexo-butterfly魔改记录大全 | Black Flies (yyyzyyyz.cn)
这里参考作者的全局吸底Aplayer教程,为方便后续自己查阅,特摘抄出来。
首先安装hexo-tag-aplayer插件,官方github;
博客根目录安装:
1 | npm install --save hexo-tag-aplayer |
由于需要全局都插入aplayer和meting资源,为了防止插入重复的资源,需要把asset_inject设为false
在hexo的配置文件中
1 | aplayer: |
在主题配置文件中,enable设为true和per_page设为true
1 | # Inject the css and script (aplayer/meting) |
在跳转页面时不关闭音乐,需要开启pjax
1 | # Pjax |
然后把代码插入到页脚中
1 | bottom: |
butterfly导航栏修改方案
点击下拉查看具体内容
新建css
1 | #nav a:hover { |
新建js
1 | // 返回顶部 显示网页阅读进度 |
修改 themes/butterfly/source/js/main.js
1 | window.scrollCollect = () => { |
修改 themes/butterfly/layout/includes/header/index.pug
其中nav-visible
可以控制默认显示的是站点标题还是导航栏菜单。
1 | if top_img !== false |
nav.pug
替换themes/butterfly/layout/includes/header/nav.pug
, 改动太多了,懒的对比了 🤡,直接替换好啦
1 | - const { darkmode } = theme |
在分类页面和archives页面添加统计图
点击下拉查看具体内容
1.安装npm(npm install hexo-butterfly-charts —save)插件
1 | npm install hexo-butterfly-charts --save |
2.修改 Butterfly config 配置
在您的_config.butterfly.yml中添加如下字段
1 | #see https://www.npmjs.com/package/hexo-butterfly-charts |
3.针对分类页面进行添加
在主题目录中: .\themes\Butterfly\layout\page.pug
如果信息差不多可以直接复制
1 | extends includes/layout.pug |
4.针对archives页面进行添加
在主题目录中 .\themes\Butterfly\layout\archive.pug,
1 | extends includes/layout.pug |
这里写了一些比较nice的魔改教程,也参考了好多博主的教程
给博客/网站顶部加上加载进度条
点击下拉查看具体内容
这里就直接上效果比较Nice一种方式咯
这种方式适合加载比较缓慢的,能够看出效果来,会消耗用户的硬件资源,影响体验
引入css文件
在/themes/butterfly/source/css/`新建一个css文件,名字自定义,这里我就以loading-bar.css命名的
1 | .pace { |
关于进度条的颜色修改主要修改如下即可
1 | background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); |
渐变网站推荐:
uiGradients - Beautiful colored gradients
关于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
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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558/*!
* pace.js v1.2.4
* https://github.com/CodeByZach/pace/
* Licensed MIT © HubSpot, Inc.
*/
!
function() {
function o(t, e) {
return function() {
return t.apply(e, arguments)
}
}
var u, c, i, s, n, y, t, l, v, r, a, p, e, h, w, b, f, g, d, m, k, S, q, L, x, P, T, R, j, O, E, M, A, C, N, _, F, U, W, X, D, H, I, z, G, B, J = [].slice,
K = {}.hasOwnProperty,
Q = function(t, e) {
for (var n in e) K.call(e, n) && (t[n] = e[n]);
function r() {
this.constructor = t
}
return r.prototype = e.prototype,
t.prototype = new r,
t.__super__ = e.prototype,
t
},
V = [].indexOf ||
function(t) {
for (var e = 0,
n = this.length; e < n; e++) if (e in this && this[e] === t) return e;
return - 1
};
function Y() {}
for (g = {
className: "",
catchupTime: 100,
initialRate: .03,
minTime: 250,
ghostTime: 100,
maxProgressPerFrame: 20,
easeFactor: 1.25,
startOnPageLoad: !0,
restartOnPushState: !0,
restartOnRequestAfter: 500,
target: "body",
elements: {
checkInterval: 100,
selectors: ["body"]
},
eventLag: {
minSamples: 10,
sampleCount: 3,
lagThreshold: 3
},
ajax: {
trackMethods: ["GET"],
trackWebSockets: !0,
ignoreURLs: []
}
},
P = function() {
var t;
return null != (t = "undefined" != typeof performance && null !== performance && "function" == typeof performance.now ? performance.now() : void 0) ? t: +new Date
},
R = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame, f = window.cancelAnimationFrame || window.mozCancelAnimationFrame, p = function(t, e, n) {
if ("function" == typeof t.addEventListener) return t.addEventListener(e, n, !1);
var r;
"function" != typeof t["on" + e] || "object" != typeof t["on" + e].eventListeners ? (r = new s, "function" == typeof t["on" + e] && r.on(e, t["on" + e]), t["on" + e] = function(t) {
return r.trigger(e, t)
},
t["on" + e].eventListeners = r) : r = t["on" + e].eventListeners,
r.on(e, n)
},
null == R && (R = function(t) {
return setTimeout(t, 50)
},
f = function(t) {
return clearTimeout(t)
}), O = function(e) {
var n = P(),
r = function() {
var t = P() - n;
return 33 <= t ? (n = P(), e(t,
function() {
return R(r)
})) : setTimeout(r, 33 - t)
};
return r()
},
j = function() {
var t = arguments[0],
e = arguments[1],
n = 3 <= arguments.length ? J.call(arguments, 2) : [];
return "function" == typeof t[e] ? t[e].apply(t, n) : t[e]
},
d = function() {
for (var t, e, n, r = arguments[0], s = 2 <= arguments.length ? J.call(arguments, 1) : [], o = 0, i = s.length; o < i; o++) if (e = s[o]) for (t in e) K.call(e, t) && (n = e[t], null != r[t] && "object" == typeof r[t] && null != n && "object" == typeof n ? d(r[t], n) : r[t] = n);
return r
},
h = function(t) {
for (var e, n, r = e = 0,
s = 0,
o = t.length; s < o; s++) n = t[s],
r += Math.abs(n),
e++;
return r / e
},
k = function(t, e) {
var n, r;
if (null == t && (t = "options"), null == e && (e = !0), r = document.querySelector("[data-pace-" + t + "]")) {
if (n = r.getAttribute("data-pace-" + t), !e) return n;
try {
return JSON.parse(n)
} catch(t) {
return "undefined" != typeof console && null !== console ? console.error("Error parsing inline pace options", t) : void 0
}
}
},
Y.prototype.on = function(t, e, n, r) {
var s;
return null == r && (r = !1),
null == this.bindings && (this.bindings = {}),
null == (s = this.bindings)[t] && (s[t] = []),
this.bindings[t].push({
handler: e,
ctx: n,
once: r
})
},
Y.prototype.once = function(t, e, n) {
return this.on(t, e, n, !0)
},
Y.prototype.off = function(t, e) {
var n, r, s;
if (null != (null != (r = this.bindings) ? r[t] : void 0)) {
if (null == e) return delete this.bindings[t];
for (n = 0, s = []; n < this.bindings[t].length;) this.bindings[t][n].handler === e ? s.push(this.bindings[t].splice(n, 1)) : s.push(n++);
return s
}
},
Y.prototype.trigger = function() {
var t, e, n, r, s, o, i = arguments[0],
a = 2 <= arguments.length ? J.call(arguments, 1) : [];
if (null != (r = this.bindings) && r[i]) {
for (n = 0, o = []; n < this.bindings[i].length;) e = (s = this.bindings[i][n]).handler,
t = s.ctx,
s = s.once,
e.apply(null != t ? t: this, a),
s ? o.push(this.bindings[i].splice(n, 1)) : o.push(n++);
return o
}
},
B = Y, y = window.Pace || {},
window.Pace = y, d(y, B.prototype), T = y.options = d({},
g, window.paceOptions, k()), X = 0, H = (z = ["ajax", "document", "eventLag", "elements"]).length; X < H; X++) ! 0 === T[C = z[X]] && (T[C] = g[C]);
function Z() {
return Z.__super__.constructor.apply(this, arguments)
}
function $() {
this.progress = 0
}
function tt() {
this.bindings = {}
}
function et() {
var e, o = this;
et.__super__.constructor.apply(this, arguments),
e = function(r) {
var s = r.open;
return r.open = function(t, e, n) {
return A(t) && o.trigger("request", {
type: t,
url: e,
request: r
}),
s.apply(r, arguments)
}
},
window.XMLHttpRequest = function(t) {
t = new W(t);
return e(t),
t
};
try {
m(window.XMLHttpRequest, W)
} catch(t) {}
if (null != U) {
window.XDomainRequest = function() {
var t = new U;
return e(t),
t
};
try {
m(window.XDomainRequest, U)
} catch(t) {}
}
if (null != F && T.ajax.trackWebSockets) {
window.WebSocket = function(t, e) {
var n = null != e ? new F(t, e) : new F(t);
return A("socket") && o.trigger("request", {
type: "socket",
url: t,
protocols: e,
request: n
}),
n
};
try {
m(window.WebSocket, F)
} catch(t) {}
}
}
function nt() {
this.complete = o(this.complete, this);
var t = this;
this.elements = [],
S().on("request",
function() {
return t.watch.apply(t, arguments)
})
}
function rt(t) {
var e, n, r, s;
for (null == t && (t = {}), this.complete = o(this.complete, this), this.elements = [], null == t.selectors && (t.selectors = []), n = 0, r = (s = t.selectors).length; n < r; n++) e = s[n],
this.elements.push(new i(e, this.complete))
}
function st(t, e) {
this.selector = t,
this.completeCallback = e,
this.progress = 0,
this.check()
}
function ot() {
var t, e, n = this;
this.progress = null != (e = this.states[document.readyState]) ? e: 100,
t = document.onreadystatechange,
document.onreadystatechange = function() {
return null != n.states[document.readyState] && (n.progress = n.states[document.readyState]),
"function" == typeof t ? t.apply(null, arguments) : void 0
}
}
function it(t) {
this.source = t,
this.last = this.sinceLastUpdate = 0,
this.rate = T.initialRate,
this.catchup = 0,
this.progress = this.lastProgress = 0,
null != this.source && (this.progress = j(this.source, "progress"))
}
B = Error,
Q(Z, B),
n = Z,
$.prototype.getElement = function() {
var t;
if (null == this.el) {
if (! (t = document.querySelector(T.target))) throw new n;
this.el = document.createElement("div"),
this.el.className = "pace pace-active",
document.body.className = document.body.className.replace(/(pace-done )|/, "pace-running ");
var e = "" !== T.className ? " " + T.className: "";
this.el.innerHTML = '<div class="pace-progress' + e + '">\n <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>',
null != t.firstChild ? t.insertBefore(this.el, t.firstChild) : t.appendChild(this.el)
}
return this.el
},
$.prototype.finish = function() {
var t = this.getElement();
return t.className = t.className.replace("pace-active", "pace-inactive"),
document.body.className = document.body.className.replace("pace-running ", "pace-done ")
},
$.prototype.update = function(t) {
return this.progress = t,
y.trigger("progress", t),
this.render()
},
$.prototype.destroy = function() {
try {
this.getElement().parentNode.removeChild(this.getElement())
} catch(t) {
n = t
}
return this.el = void 0
},
$.prototype.render = function() {
var t, e, n, r, s, o, i;
if (null == document.querySelector(T.target)) return ! 1;
for (t = this.getElement(), r = "translate3d(" + this.progress + "%, 0, 0)", s = 0, o = (i = ["webkitTransform", "msTransform", "transform"]).length; s < o; s++) e = i[s],
t.children[0].style[e] = r;
return (!this.lastRenderedProgress || this.lastRenderedProgress | 0 !== this.progress | 0) && (t.children[0].setAttribute("data-progress-text", (0 | this.progress) + "%"), 100 <= this.progress ? n = "99": (n = this.progress < 10 ? "0": "", n += 0 | this.progress), t.children[0].setAttribute("data-progress", "" + n)),
y.trigger("change", this.progress),
this.lastRenderedProgress = this.progress
},
$.prototype.done = function() {
return 100 <= this.progress
},
c = $,
tt.prototype.trigger = function(t, e) {
var n, r, s, o, i;
if (null != this.bindings[t]) {
for (i = [], r = 0, s = (o = this.bindings[t]).length; r < s; r++) n = o[r],
i.push(n.call(this, e));
return i
}
},
tt.prototype.on = function(t, e) {
var n;
return null == (n = this.bindings)[t] && (n[t] = []),
this.bindings[t].push(e)
},
s = tt,
W = window.XMLHttpRequest,
U = window.XDomainRequest,
F = window.WebSocket,
m = function(t, e) {
var n, r = [];
for (n in e.prototype) try {
null == t[n] && "function" != typeof e[n] ? "function" == typeof Object.defineProperty ? r.push(Object.defineProperty(t, n, {
get: function(t) {
return function() {
return e.prototype[t]
}
} (n),
configurable: !0,
enumerable: !0
})) : r.push(t[n] = e.prototype[n]) : r.push(void 0)
} catch(t) {
0
}
return r
},
L = [],
y.ignore = function() {
var t = arguments[0],
e = 2 <= arguments.length ? J.call(arguments, 1) : [];
return L.unshift("ignore"),
e = t.apply(null, e),
L.shift(),
e
},
y.track = function() {
var t = arguments[0],
e = 2 <= arguments.length ? J.call(arguments, 1) : [];
return L.unshift("track"),
e = t.apply(null, e),
L.shift(),
e
},
A = function(t) {
if (null == t && (t = "GET"), "track" === L[0]) return "force";
if (!L.length && T.ajax) {
if ("socket" === t && T.ajax.trackWebSockets) return ! 0;
if (t = t.toUpperCase(), 0 <= V.call(T.ajax.trackMethods, t)) return ! 0
}
return ! 1
},
Q(et, s),
t = et,
D = null,
M = function(t) {
for (var e, n = T.ajax.ignoreURLs,
r = 0,
s = n.length; r < s; r++) if ("string" == typeof(e = n[r])) {
if ( - 1 !== t.indexOf(e)) return ! 0
} else if (e.test(t)) return ! 0;
return ! 1
},
(S = function() {
return D = null == D ? new t: D
})().on("request",
function(t) {
var o, i = t.type,
a = t.request,
e = t.url;
if (!M(e)) return y.running || !1 === T.restartOnRequestAfter && "force" !== A(i) ? void 0 : (o = arguments, "boolean" == typeof(e = T.restartOnRequestAfter || 0) && (e = 0), setTimeout(function() {
var t, e, n, r, s = "socket" === i ? a.readyState < 1 : 0 < (s = a.readyState) && s < 4;
if (s) {
for (y.restart(), r = [], t = 0, e = (n = y.sources).length; t < e; t++) {
if ((C = n[t]) instanceof u) {
C.watch.apply(C, o);
break
}
r.push(void 0)
}
return r
}
},
e))
}),
nt.prototype.watch = function(t) {
var e = t.type,
n = t.request,
t = t.url;
if (!M(t)) return n = new("socket" === e ? r: a)(n, this.complete),
this.elements.push(n)
},
nt.prototype.complete = function(e) {
return this.elements = this.elements.filter(function(t) {
return t !== e
})
},
u = nt,
a = function(e, n) {
var t, r, s, o, i = this;
if (this.progress = 0, null != window.ProgressEvent) for (p(e, "progress",
function(t) {
return t.lengthComputable ? i.progress = 100 * t.loaded / t.total: i.progress = i.progress + (100 - i.progress) / 2
}), t = 0, r = (o = ["load", "abort", "timeout", "error"]).length; t < r; t++) p(e, o[t],
function() {
return n(i),
i.progress = 100
});
else s = e.onreadystatechange,
e.onreadystatechange = function() {
var t;
return 0 === (t = e.readyState) || 4 === t ? (n(i), i.progress = 100) : 3 === e.readyState && (i.progress = 50),
"function" == typeof s ? s.apply(null, arguments) : void 0
}
},
r = function(t, e) {
for (var n, r = this,
s = this.progress = 0,
o = (n = ["error", "open"]).length; s < o; s++) p(t, n[s],
function() {
return e(r),
r.progress = 100
})
},
rt.prototype.complete = function(e) {
return this.elements = this.elements.filter(function(t) {
return t !== e
})
},
k = rt,
st.prototype.check = function() {
var t = this;
return document.querySelector(this.selector) ? this.done() : setTimeout(function() {
return t.check()
},
T.elements.checkInterval)
},
st.prototype.done = function() {
return this.completeCallback(this),
this.completeCallback = null,
this.progress = 100
},
i = st,
ot.prototype.states = {
loading: 0,
interactive: 50,
complete: 100
},
B = ot,
Q = function() {
var e, n, r, s, o, i = this;
this.progress = 0,
o = [],
s = 0,
r = P(),
n = setInterval(function() {
var t = P() - r - 50;
return r = P(),
o.push(t),
o.length > T.eventLag.sampleCount && o.shift(),
e = h(o),
++s >= T.eventLag.minSamples && e < T.eventLag.lagThreshold ? (i.progress = 100, clearInterval(n)) : i.progress = 3 / (e + 3) * 100
},
50)
},
it.prototype.tick = function(t, e) {
return 100 <= (e = null == e ? j(this.source, "progress") : e) && (this.done = !0),
e === this.last ? this.sinceLastUpdate += t: (this.sinceLastUpdate && (this.rate = (e - this.last) / this.sinceLastUpdate), this.catchup = (e - this.progress) / T.catchupTime, this.sinceLastUpdate = 0, this.last = e),
e > this.progress && (this.progress += this.catchup * t),
e = 1 - Math.pow(this.progress / 100, T.easeFactor),
this.progress += e * this.rate * t,
this.progress = Math.min(this.lastProgress + T.maxProgressPerFrame, this.progress),
this.progress = Math.max(0, this.progress),
this.progress = Math.min(100, this.progress),
this.lastProgress = this.progress,
this.progress
},
v = it,
b = e = _ = w = E = N = null,
y.running = !1,
q = function() {
if (T.restartOnPushState) return y.restart()
},
null != window.history.pushState && (I = window.history.pushState, window.history.pushState = function() {
return q(),
I.apply(window.history, arguments)
}),
null != window.history.replaceState && (G = window.history.replaceState, window.history.replaceState = function() {
return q(),
G.apply(window.history, arguments)
}),
l = {
ajax: u,
elements: k,
document: B,
eventLag: Q
},
(x = function() {
var t, e, n, r, s, o, i, a;
for (y.sources = N = [], e = 0, r = (o = ["ajax", "elements", "document", "eventLag"]).length; e < r; e++) ! 1 !== T[t = o[e]] && N.push(new l[t](T[t]));
for (n = 0, s = (a = null != (i = T.extraSources) ? i: []).length; n < s; n++) C = a[n],
N.push(new C(T));
return y.bar = w = new c,
E = [],
_ = new v
})(),
y.stop = function() {
return y.trigger("stop"),
y.running = !1,
w.destroy(),
b = !0,
null != e && ("function" == typeof f && f(e), e = null),
x()
},
y.restart = function() {
return y.trigger("restart"),
y.stop(),
y.start()
},
y.go = function() {
var m;
return y.running = !0,
w.render(),
m = P(),
b = !1,
e = O(function(t, e) {
w.progress;
for (var n, r, s, o, i, a, u, c, l, p, h = a = 0,
f = !0,
g = u = 0,
d = N.length; u < d; g = ++u) for (C = N[g], i = null != E[g] ? E[g] : E[g] = [], s = c = 0, l = (r = null != (p = C.elements) ? p: [C]).length; c < l; s = ++c) o = r[s],
f &= (o = null != i[s] ? i[s] : i[s] = new v(o)).done,
o.done || (h++, a += o.tick(t));
return n = a / h,
w.update(_.tick(t, n)),
w.done() || f || b ? (w.update(100), y.trigger("done"), setTimeout(function() {
return w.finish(),
y.running = !1,
y.trigger("hide")
},
Math.max(T.ghostTime, Math.max(T.minTime - (P() - m), 0)))) : e()
})
},
y.start = function(t) {
d(T, t),
y.running = !0;
try {
w.render()
} catch(t) {
n = t
}
return document.querySelector(".pace") ? (y.trigger("start"), y.go()) : setTimeout(y.start, 50)
},
"function" == typeof define && define.amd ? define(function() {
return y
}) : "object" == typeof exports ? module.exports = y: T.startOnPageLoad && y.start()
}.call(this);
_config.butterfly.yml主题文件中加入
1 | inject: |
网站标题部分的增强版
点击下拉查看具体内容
看到洪哥他们的有一个非常高大上的动画,一直没有实现,看到博主LYXの小破站 (yisous.xyz)的教程实现了,就整了一下
引入css,然后根据自己需要进行修改颜色,尺寸即可
1 | #site-name::before{ |
_config.butterfly.yml主题文件中加入
记得在_config.butterfly.yml引入哦
菜单栏居中
点击下拉查看具体内容
这个直接引入css文件即可
1 | .layout{ |
_config.butterfly.yml主题文件中加入
记得在_config.butterfly.yml引入哦
Categories Magnet【磁贴】
点击下拉查看具体内容
最新文章标志
点击下拉查看具体内容
此部分参考添加最新文章标志 | Jayhrn - 分享科技与热爱生活
非修改源码方案
- 1.新建 [BlogSource]/themes/butterfly/source/js/custom/newest_post.js 文件:
1 | // 旧版,本站采用 |
1 | // 新代码,利用创建时间来判断 |
- 2.新建 [BlogSource]/themes/butterfly/source/css/custom/newest_post.css 文件:
1 | .newPost-left, |
- 3.引入css和js
1 | inject: |
Hexo 白昼切换
点击下拉查看具体内容
看惯了Hexo Butterfly默认的黑夜/白天效果,正好看到 Jayhrnの糖衣阁大佬的黑白切换效果超级nice,所以也是第一时间换上了,下面告诉大家一下相关配置,相关文件大家也是可以在Gitee上找到的,链接我放底下了哦
(1)在themes\butterfly\layout\includes\custom\下新建一个sun_moon.pug【如果includes\下没有custom,记得自己创建哦】
主要用途:通过 js 操作它的旋转显隐,淡入淡出实现动画效果
1 | svg(aria-hidden='true', style='position:absolute; overflow:hidden; width:0; height:0') |
(2)themes\butterfly\source\css_layout\文件夹中新建一个sun_moon.styl
1 | .Cuteen_DarkSky, |
(3)在\themes\butterfly\source\js\custom\下新建sun_moon.js【如果js\下没有custom,记得自己创建哦】
1 | function switchNightMode() { |
(4)修改 [Blogroot]\themes\butterfly\layout\includes\head.pug
1 | //- global config |
(5)修改 [Blogroot]\themes\butterfly\layout\includes\rightside.pug, 把原本的昼夜切换按钮替换掉
1 | when 'translate' |
(6)修改 [Blogroot]_config.butterfly.yml, 引入一下 js
1 | inject: |
下面就是老规矩,把用到的文件放到gitee上了哦,记得点
- 感谢你赐予我前进的力量