框架:hexo-4.10.0
主题:butterfly

博客文章使用永久链接

参考:https://www.imbhj.com/posts/b6a99401/

hexo默认的文章链接为年+月+日+文章标题,在修改标题或时间后,原来的链接会404,并且使用中文标题的话,url转码会非常难看,例如

image-20240603161717339

安装插件

npm install hexo-abbrlink --save

修改配置文件

修改_config.yml:

1
2
## permalink: :year/:month/:day/:title/
permalink: posts/:abbrlink.html ## 此处可以自己设置

增加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
## abbrlink config
abbrlink:
alg: crc32 #support crc16(default) and crc32 进制
rep: hex #support dec(default) and hex 算法
drafts: false #(true)Process draft,(false)Do not process draft. false(default)
## Generate categories from directory-tree
## depth: the max_depth of directory-tree you want to generate, should > 0
auto_category:
enable: true #true(default)
depth: #3(default)
over_write: false
auto_title: false #enable auto title, it can auto fill the title by path
auto_date: false #enable auto date, it can auto fill the date by time today
force: false #enable force mode,in this mode, the plugin will ignore the cache, and calc the abbrlink for every post even it already had abbrlink.

效果

image-20240603163033853

添加顶部胶囊进度条

参考:https://blog.anheyu.com/posts/52d8.html

修改 themes/butterfly/layout/includes/loading/fullpage-loading.pug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#loading-box(onclick='document.getElementById("loading-box").classList.add("loaded")')
.loading-bg
div.loading-img
.loading-image-dot

script.
const preloader = {
endLoading: () => {
document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = '';
document.getElementById('loading-box').classList.remove("loaded")

}
}
window.addEventListener('load',()=> { preloader.endLoading() })

if (!{theme.pjax && theme.pjax.enable}) {
document.addEventListener('pjax:send', () => { preloader.initLoading() })
document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}

修改themes/butterfly/layout/includes/loading/index.pug

1
2
3
4
5
6
7
if theme.preloader.source === 1
include ./fullpage-loading.pug
else if theme.preloader.source === 2
include ./pace.pug
else
include ./fullpage-loading.pug
include ./pace.pug

新建source/css/progress_bar.css

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
.pace {
-webkit-pointer-events: none;
pointer-events: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
z-index: 2000;
position: fixed;
margin: auto;
top: 10px;
left: 0;
right: 0;
height: 8px;
border-radius: 8px;
width: 4rem;
background: #eaecf2;
border: 1px #e3e8f7;
overflow: hidden;
}

.pace-inactive .pace-progress {
opacity: 0;
transition: 0.3s ease-in;
}

.pace .pace-progress {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
max-width: 200px;
position: absolute;
z-index: 2000;
display: block;
top: 0;
right: 100%;
height: 100%;
width: 100%;
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
animation: gradient 1.5s ease infinite;
background-size: 200%;
}

.pace.pace-inactive {
opacity: 0;
transition: 0.3s;
top: -8px;
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}

修改themes/butterfly/source/css/_layout/loading.styl

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
if hexo-config('preloader')
.loading-bg
display: flex;
width: 100%;
height: 100%;
position: fixed;
background: var(--anzhiyu-card-bg);
z-index: 1001;
opacity: 1;
transition: .3s;

#loading-box
.loading-img
width: 100px;
height: 100px;
border-radius: 50%;
margin: auto;
border: 4px solid #f0f0f2;
animation-duration: .3s;
animation-name: loadingAction;
animation-iteration-count: infinite;
animation-direction: alternate;
.loading-image-dot
width: 30px;
height: 30px;
background: #6bdf8f;
position: absolute;
border-radius: 50%;
border: 6px solid #fff;
top: 50%;
left: 50%;
transform: translate(18px, 24px);
&.loaded
.loading-bg
opacity: 0;
z-index: -1000;

@keyframes loadingAction
0% {
opacity: 1;
}

100% {
opacity: .4;
}

新建themes/butterfly/source/css/loading.css,注意img_url处为头像链接

1
2
3
4
.loading-img {
background: url(img_url) no-repeat center center;
background-size: cover;
}

最后修改_config.butterfly.yml中preloader选项, 改完以后source: 1为满屏加载无pace胶囊,source: 2为pace胶囊无满屏动画, source: 3是两者都启用。

1
2
3
4
5
6
7
8
9
10
11
# Loading Animation (加载动画)
preloader:
enable: true
# source
# 1. fullpage-loading
# 2. pace (progress bar)
# else all
source: 3
# pace theme (see https://codebyzach.github.io/pace/)
pace_css_url: /css/progress_bar.css
avatar: # 自定义头像

导航栏修改

导入自定义css,使导航栏居中

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
/* 颜色 */
:root {
--g0ubu1i-theme-op: #050505;
--g0ubu1i-white: #fff;
--g0ubu1i-black: #000;
--g0ubu1i-none: rgba(0, 0, 0, 0);
--g0ubu1i-gray: #999999;
--g0ubu1i-yellow: #ffc93e;
--g0ubu1i-border-radius: 8px;
--g0ubu1i-main: var(--g0ubu1i-theme);
--g0ubu1i-main-op: var(--g0ubu1i-theme-op);
--g0ubu1i-shadow-theme: 0 8px 12px -3px var(--g0ubu1i-theme-op);
--g0ubu1i-shadow-main: 0 8px 12px -3px var(--g0ubu1i-main-op);
--g0ubu1i-shadow-blue: 0 8px 12px -3px rgba(40, 109, 234, 0.2);
--g0ubu1i-shadow-white: 0 8px 12px -3px rgba(255, 255, 255, 0.2);
--g0ubu1i-shadow-black: 0 0 12px 4px rgba(0, 0, 0, 0.05);
--g0ubu1i-shadow-yellow: 0px 38px 77px -26px rgba(255, 201, 62, 0.12);
--g0ubu1i-shadow-red: 0 8px 12px -3px #ee7d7936;
--g0ubu1i-shadow-green: 0 8px 12px -3px #87ee7936;
--g0ubu1i-shadow-border: 0 8px 16px -4px #2c2d300c;
--g0ubu1i-logo-color: linear-gradient(215deg, #4584ff 30%, #ff7676 70%);
--style-border: 1px solid var(--g0ubu1i-card-border);
--g0ubu1i-blue-main: #3b70fc;
--style-border-hover: 1px solid var(--g0ubu1i-main);
--style-border-dashed: 1px dashed var(--g0ubu1i-theme-op);
--style-border-avatar: 4px solid var(--g0ubu1i-background);
--style-border-always: 1px solid var(--g0ubu1i-card-border);
--g0ubu1i-white-acrylic1: #fefeff !important;
--g0ubu1i-white-acrylic2: #fcfdff !important;
--g0ubu1i-black-acrylic2: #08080a !important;
--g0ubu1i-black-acrylic1: #0b0b0e !important;
}

[data-theme="light"] {
--g0ubu1i-theme: #3b70fc;
--g0ubu1i-theme-op: #4259ef23;
--g0ubu1i-blue: #3b70fc;
--g0ubu1i-red: #d8213c;
--g0ubu1i-pink: #ff7c7c;
--g0ubu1i-green: #57bd6a;
--g0ubu1i-fontcolor: #363636;
--g0ubu1i-background: #f7f9fe;
--g0ubu1i-reverse: #000;
--g0ubu1i-maskbg: rgba(255, 255, 255, 0.6);
--g0ubu1i-maskbgdeep: rgba(255, 255, 255, 0.85);
--g0ubu1i-hovertext: var(--g0ubu1i-theme);
--g0ubu1i-ahoverbg: #f7f7fa;
--g0ubu1i-lighttext: var(--g0ubu1i-main);
--g0ubu1i-secondtext: rgba(60, 60, 67, 0.6);
--g0ubu1i-scrollbar: rgba(60, 60, 67, 0.4);
--g0ubu1i-card-btn-bg: #edf0f7;
--g0ubu1i-post-blockquote-bg: #fafcff;
--g0ubu1i-post-tabs-bg: #f2f5f8;
--g0ubu1i-secondbg: #edf0f7;
--g0ubu1i-shadow-nav: 0 5px 12px -5px rgba(102, 68, 68, 0.05);
--g0ubu1i-card-bg: #fff;
--g0ubu1i-shadow-lightblack: 0 5px 12px -5px rgba(102, 68, 68, 0);
--g0ubu1i-shadow-light2black: 0 5px 12px -5px rgba(102, 68, 68, 0);
--g0ubu1i-card-border: #c0c6d8;
}

[data-theme="dark"] {
--g0ubu1i-theme: #0084ff;
--g0ubu1i-theme-op: #0084ff23;
--g0ubu1i-blue: #0084ff;
--g0ubu1i-red: #ff3842;
--g0ubu1i-pink: #ff7c7c;
--g0ubu1i-green: #57bd6a;
--g0ubu1i-fontcolor: #f7f7fa;
--g0ubu1i-background: #18171d;
--g0ubu1i-reverse: #fff;
--g0ubu1i-maskbg: rgba(0, 0, 0, 0.6);
--g0ubu1i-maskbgdeep: rgba(0, 0, 0, 0.85);
--g0ubu1i-hovertext: #0a84ff;
--g0ubu1i-ahoverbg: #fff;
--g0ubu1i-lighttext: #f2b94b;
--g0ubu1i-secondtext: #a1a2b8;
--g0ubu1i-scrollbar: rgba(200, 200, 223, 0.4);
--g0ubu1i-card-btn-bg: #30343f;
--g0ubu1i-post-blockquote-bg: #000;
--g0ubu1i-post-tabs-bg: #121212;
--g0ubu1i-secondbg: #30343f;
--g0ubu1i-shadow-nav: 0 5px 20px 0px rgba(28, 28, 28, 0.4);
--g0ubu1i-card-bg: #1d1b26;
--g0ubu1i-shadow-lightblack: 0 5px 12px -5px rgba(102, 68, 68, 0);
--g0ubu1i-shadow-light2black: 0 5px 12px -5px rgba(102, 68, 68, 0);
--g0ubu1i-card-border: #42444a;
}

#nav a:hover {
background: var(--g0ubu1i-blue-main);
transition: 0.3s;
}

#nav-totop:hover .totopbtn i {
opacity: 1;
}
#nav-totop #percent {
font-size: 12px;
background: var(--g0ubu1i-white);
color: var(--g0ubu1i-main);
width: 25px;
height: 25px;
border-radius: 35px;
display: flex;
justify-content: center;
align-items: center;
transition: 0.3s;
}
.nav-fixed #nav-totop #percent,
.page #nav-totop #percent {
background: var(--g0ubu1i-white);
color: var(--card-bg);
font-size: 13px;
}

#nav-totop {
width: 35px;
}
#page-header:not(.is-top-bar) #percent {
transition: 0.3s;
}
#page-header:not(.is-top-bar) #nav-totop {
width: 0;
opacity: 0;
transition: width 0.3s, opacity 0.2s;
margin-left: 0 !important;
}
#nav-totop #percent {
font-weight: 700;
}
#nav-totop:hover #percent {
opacity: 0;
transform: scale(1.5);
font-weight: 700;
}
#page-header #nav #nav-right div {
margin-left: 0.5rem;
padding: 0;
}

#nav-totop {
display: flex;
align-items: center;
justify-content: center;
transition: 0.3s;
}
.nav-button {
cursor: pointer;
}
div#menus {
display: flex;
align-items: center;
}
#page-header #nav .nav-button a {
height: 35px;
width: 35px;
display: flex;
align-items: center;
justify-content: center;
}

#nav .site-page {
padding-bottom: 0px;
}
#nav *::after {
background-color: transparent !important;
}

/* 顶栏修改 */
#nav .menus_items .menus_item .menus_item_child li a {
padding: 2px 16px;
}
#nav .menus_items .menus_item .menus_item_child li:hover a {
color: white !important;
}

#nav .menus_items .menus_item .menus_item_child li {
margin: 6px;
border-radius: 5px;
transition: all 0.3s;
display: inline-block;
margin: 0 3px;
}
#nav .menus_items .menus_item .menus_item_child:before {
top: -19px;
}
#site-name,
.shuoshuo {
white-space: nowrap;
overflow: hidden;
}
#site-name {
padding: 0 8px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
transition: 0.3s;
}

#blog_name #site-name i {
opacity: 0;
position: absolute;
}

#blog_name #site-name:hover .title {
opacity: 0;
}

#blog_name #site-name:hover i {
opacity: 1;
transform: scale(1.01);
color: white;
}
/* 圆角隐藏 */
ul.menus_item_child {
border-radius: 5px;
}

/* 一级菜单居中 */
#nav .menus_items {
position: absolute;
width: fit-content;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
height: 60px;
}

#nav .menus_items .menus_item:hover .menus_item_child {
display: block;
transform: translateX(-50%);
right: auto;
left: auto !important;
padding: 6px 4px;
box-sizing: content-box;
line-height: 35px;
}
#nav .menus_items .menus_item:hover {
padding: 0 5px 27px 5px !important;
margin-bottom: -14.5px !important;
}

#nav .menus_items .menus_item .menus_item_child {
top: 44px;
}

@media screen and (min-width: 768px) {
.page .menus_item:hover > a.site-page {
color: var(--g0ubu1i-white) !important;
background: var(--g0ubu1i-main);
transition: 0.3s;
box-shadow: var(--g0ubu1i-shadow-main);
}
}

.nav-fixed #nav {
transform: translateY(58px) !important;
}
#nav {
padding: 0 calc((100% - 1420px) / 2);
backdrop-filter: saturate(180%) blur(20px);
}

#nav a {
border-radius: 8px;
color: var(--font-color);
}
.page #nav a:hover {
color: var(--g0ubu1i-white) !important;
background: var(--g0ubu1i-main);
transition: 0.3s;
box-shadow: var(--g0ubu1i-shadow-main);
}

#menus > div.menus_items > div > a {
letter-spacing: 0.3rem;
font-weight: 700;
padding: 0em 0.3em 0em 0.5em;
height: 35px;
line-height: 35px;
}
#nav .menus_items .menus_item {
padding: 0 5px;
display: flex;
flex-direction: column;
margin: auto;
align-items: center;
}

#nav div#toggle-menu {
padding: 2px 0 4px 6px;
}

#nav-totop .totopbtn i {
position: absolute;
display: flex;
opacity: 0;
}
#page-name::before {
font-size: 18px;
position: absolute;
width: 100%;
height: 100%;
border-radius: 8px;
color: white !important;
top: 0;
left: 0;
content: "回到顶部";
background-color: var(--g0ubu1i-theme);
transition: all 0.3s;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
opacity: 0;
box-shadow: 0 0 3px var(--g0ubu1i-theme);
line-height: 45px; /*如果垂直位置不居中可以微调此值,也可以删了*/
}
#page-name:hover:before {
opacity: 1;
}
#name-container {
transition: all 0.3s;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
}
#name-container:hover {
transform: translateX(-50%) scale(1.03);
}
#page-name {
position: relative;
padding: 10px 30px;
-webkit-animation-timing-function: ease-out;
}

center#name-container {
position: absolute;
width: 100%;
left: 50%;
transform: translateX(-50%);
font-family: "ZhuZiAYuanJWD";
}
.nav-fixed.nav-visible #name-container {
transition: 0.3s;
transform: translate(-50%, 60px);
}
.nav-fixed.nav-visible #menus .menus_items {
transform: translate(-50%);
transition: 0.3s;
line-height: 60px;
}
.nav-fixed #menus .menus_items {
transform: translate(-50%, -60px);
transition: 0.3s;
}
.nav-fixed #name-container {
top: 15%;
transition: 0.3s;
}
#name-container {
bottom: 60px;
}

.mask-name-container {
max-width: 1200px;
width: 50%;
height: 100%;
position: absolute;
overflow: hidden;
left: 50%;
transform: translateX(-50%);
}

@media screen and (max-width: 992px) {
.mask-name-container {
width: 65%;
}
}

@media screen and (max-width: 768px) {
.mask-name-container {
display: none;
}
}
#sidebar #sidebar-menus .menus_items .site-page:hover {
color: var(--g0ubu1i-white);
border-radius: var(--g0ubu1i-border-radius);
}
#nav .menus_items .menus_item > a > i:last-child {
display: none;
}
#nav #search-button {
font-size: 1.3em;
}

@media screen and (min-width: 900px) {
#nav .back-home-button:hover {
box-shadow: var(--g0ubu1i-shadow-main);
}
}

.back-home-button:hover {
background: var(--g0ubu1i-main);
color: var(--g0ubu1i-white) !important;
}
.back-home-button {
display: flex;
width: 35px;
height: 35px;
padding: 0 !important;
align-items: center;
justify-content: center;
margin-right: 4px;
transition: 0.3s;
border-radius: 8px;
}

.back-home-button:hover .back-menu-list-groups {
display: flex;
opacity: 1;
transition: 0.3s;
top: 55px;
pointer-events: auto;
left: 0;
}
.back-home-button .back-menu-list-groups {
position: absolute;
top: 65px;
left: 0;
background: var(--g0ubu1i-card-bg);
border-radius: 12px;
border: var(--style-border);
flex-direction: column;
font-size: 12px;
color: var(--g0ubu1i-secondtext);
box-shadow: var(--g0ubu1i-shadow-border);
transition: 0s;
opacity: 0;
pointer-events: none;
}

.back-home-button .back-menu-list-group {
display: flex;
flex-direction: column;
}
.back-home-button .back-menu-list-group .back-menu-list-title {
margin: 8px 0 0 16px;
transition: 0.3s;
}
.back-home-button .back-menu-list {
display: flex;
flex-direction: column;
}
.back-home-button .back-menu-list::before {
position: absolute;
top: -22px;
left: 0px;
width: 100%;
height: 25px;
content: "";
}

.back-home-button .back-menu-list-group:hover .back-menu-list-title {
color: var(--g0ubu1i-main);
}
.back-home-button .back-menu-list-groups:hover {
border: var(--style-border-hover);
}
.back-home-button .back-menu-list .back-menu-item {
display: flex;
align-items: center;
margin: 4px 8px;
padding: 4px 8px !important;
transition: 0.3s;
border-radius: 8px;
}
.back-home-button .back-menu-list .back-menu-item .back-menu-item-text {
font-size: var(--global-font-size);
margin-left: 0.5rem;
color: var(--g0ubu1i-fontcolor);
white-space: nowrap;
}
#nav #blog_name {
flex-wrap: nowrap;
height: 60px;
display: flex;
align-items: center;
/* z-index: 102; */
transition: 0.3s;
}
.back-home-button .back-menu-list .back-menu-item .back-menu-item-icon {
width: 24px;
height: 24px;
border-radius: 24px;
background: var(--g0ubu1i-secondbg);
}
#page-header #nav .back-home-button {
cursor: pointer;
position: relative;
}

@media screen and (min-width: 1300px) {
#nav a:hover {
transform: scale(1.03);
}
}
.back-home-button .back-menu-list .back-menu-item:hover .back-menu-item-text {
color: var(--g0ubu1i-white);
}
.back-menu-item-icon.loading img {
width: 25px;
}

#page-header #nav #menus .nav-button.long a.totopbtn,
#page-header #nav #menus .nav-button.long,
#page-header #nav #menus .nav-button.long a.totopbtn span {
width: 70px;
}
#page-header #nav #menus .nav-button.long a.totopbtn span {
border-radius: 35px;
display: flex;
justify-content: center;
align-items: center;
transition: 0.3s;
white-space: nowrap;
}

#page-header #nav #menus .nav-button.long a.totopbtn:hover {
border-radius: 35px;
height: 30px;
}

#nav #search-button {
padding-left: 0;
}
#page-header #nav .nav-button {
margin-left: 0.5rem;
padding: 0;
}
#page-header:not(.is-top-bar) #nav-totop a {
display: none;
}
#search-button a.site-page.social-icon.search span {
display: none;
}

链接卡片化

参考:https://blog.zhheo.com/p/ccaf9148.html

添加外置标签

新建文件themes/butterfly/scripts/tag/link.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
function link(args) {
args = args.join(' ').split(',');
let title = args[0];
let sitename = args[1];
let link = args[2];

// 获取网页favicon
let urlNoProtocol = link.replace(/^https?\:\/\//i, "");
let imgUrl = "https://api.iowen.cn/favicon/" + urlNoProtocol + ".png";

return `<a class="tag-Link" target="_blank" href="${link}">
<div class="tag-link-tips">引用站外地址</div>
<div class="tag-link-bottom">
<div class="tag-link-left" style="background-image: url(${imgUrl});"></div>
<div class="tag-link-right">
<div class="tag-link-title">${title}</div>
<div class="tag-link-sitename">${sitename}</div>
</div>
<i class="fa-solid fa-angle-right"></i>
</div>
</a>`
}

hexo.extend.tag.register('link',link, { ends: false })

添加css

1
2
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zhheo/JS-Heo@master/mainColor/heoMainColor.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zhheo/JS-Heo@main/tag-link/tag-link.css">

测试: