感谢Leonus大佬前面的帮助

修改page.pug文件

[blogRoot]\themes\butterfly\layout\page.pug中添加如下代码:

这里注意缩进,pug格式文件对缩进要求严格,注意对齐。

1
2
3
4
5
6
7
8
      when 'tags'
include includes/page/tags.pug
when 'link'
include includes/page/flink.pug
when 'categories'
include includes/page/categories.pug
+ when 'collect'
+ include includes/page/collect.pug

新建collect.pug文件

[blogRoot]\themes\butterfly\layout\includes\page下新建collect.pug文件并粘贴如下代码:

top_img我直接用安知鱼的,复制粘贴过来的,就加了图片显示,如果需要的直接把[blogroot]\themes\anzhiyu\layout\includes\page\下的album.pug文件下的代码进行复制粘贴即可(不是全部,只需要前面的),加载方式如下(注意缩进):

1
2
+  .author-content.author-content-item.album.single(style = `background: url(https://images.wallpaperscraft.com/image/single/girl_twilight_clouds_156445_2560x1080.jpg) left 28% / cover no-repeat !important;`)
- .author-content.author-content-item.album.single

这里的b标签看情况而定,由于我基本上不做什么更改,这里就没写成获取变量值,如果有需要的请自行更改。

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
blockquote
b 一些收藏
.hexo-collect-show
- let gamesPageContent = page.content
if site.data.games
- let result = ""
each i in site.data.games
- let className = i.class_name ? `<h2 ${i.class_desc?'':'style="margin-bottom:12px"'}>${i.class_name}</h2>` : ""
- let classDesc = i.class_desc ? `<div class="collect-desc">${i.class_desc}</div>` : ""
- let listResult = ""
each item in i.link_list
-
listResult += `
<div class="hexo-collect-item">
<div class="hexo-collect-picture" title="${item.name}">
<a target="_blank" href="${item.link}" rel="external nofollow">
<img src="${item.cover}" data-src="${item.cover}" referrerpolicy="no-referrer">
</a>
</div>
<div class="hexo-collect-info">
<div class="hexo-collect-title" title="${item.name}">
<a target="_blank" href="${item.link}" rel="external nofollow">${item.name}</a>
</div>
<div class="bber-reply" onclick="rm.rightMenuCommentText('${item.name}')">
<i class="fas fa-message" style="cursor:pointer;float:right;right:10px;bottom:5px;position:absolute;"></i>
</div>
<div class="hexo-collect-meta">${item.date_grade}</div>
<div class="hexo-collect-comments">${item.comment?item.comment:'暂无评论'}</div>
</div>
</div>
`
-
- result += `${className}${classDesc} <div id="hexo-collect-item3">${listResult}</div>`
- gamesPageContent = gamesPageContent + result
!= gamesPageContent

blockquote
b 那些年看的视频
.collect
- let collectPageContent = page.content
if site.data.collect
- let result = ""
each i in site.data.collect
- let className = i.class_name ? `<h2 ${i.class_desc?'':'style="margin-bottom:12px"'}>${i.class_name}</h2>` : ""
- let classDesc = i.class_desc ? `<div class="collect-desc">${i.class_desc}</div>` : ""
- let listResult = ""
each j in i.link_list
-
listResult += `
<div title="${j.name}" referrerPolicy="no-referrer" class="collect_box" style="${j.img?`background-image: url(${j.img})`:'background-color: #333;'}">
<div class="collect-div"><a target="_blank" href="${j.link}" rel="external nofollow"></a></div>
<div class="collect_top">
<i class="${j.icon?j.icon:'fa-solid fa-film'}"></i>
<span>${j.tip?j.tip:'电影'}</span>
</div>
<div class="collect_content">
<span>${j.name?j.name:'未知'}</span>
<div>${j.score?toStar(j.score):toStar(0)}</div>
</div>
</div>
`
-
- result += `${className}${classDesc} <div class="collect-list">${listResult}</div>`
- collectPageContent = collectPageContent + result
!= collectPageContent

自定义css文件

有需要的自行更改为style文件,只是转换了而已,为了让小白很好理解和微改,这里就转换为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
/* 藏宝阁 */
.collect-item-content {
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin: 0 -8px;
}

.collect-item-content-item {
width: calc(25% - 12px);
border-radius: 12px;
border: 1px solid #e3e8f7;
overflow: hidden;
margin: 8px 6px;
background: #fff;
box-shadow: 0 8px 16px -4px #2c2d300c;
min-height: 400px;
position: relative;
}

@media screen and (max-width: 1200px) {
.collect-item-content-item {
width: calc(50% - 12px);
}
}

@media screen and (max-width: 768px) {
.collect-item-content-item {
width: 100%;
}
}

.collect-item-content-item-info {
padding: 8px 16px 16px 16px;
margin-top: 12px;
}

.collect-item-content-item-name {
font-size: 18px;
font-weight: bold;
line-height: 1;
margin-bottom: 8px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: fit-content;
}

.collect-item-content-item-specification {
font-size: 12px;
color: #3c3c43cc;
line-height: 1;
margin-bottom: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.collect-item-content-item-description {
line-height: 20px;
color: #3c3c43cc;
height: 60px;
display: -webkit-box;
overflow: hidden;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
font-size: 14px;
}

a.collect-item-content-item-link {
font-size: 12px;
background: #9999992b;
padding: 4px 8px;
border-radius: 8px;
cursor: pointer;
}

a.collect-item-content-item-link:hover {
background: #425aef !important;
color: #fff;
}

h2.collect-item-title {
line-height: 1;
}

.collect-item-description {
line-height: 1;
margin: 4px 0 8px 0;
color: #3c3c43cc;
}

.collect-item-content-item-cover {
width: 100%;
height: 200px;
background: #f1f3f8;
display: flex;
justify-content: center;
}

img.collect-item-content-item-image {
object-fit: cover;
height: 100%;
}

div#collect {
margin-top: 26px;
}

.collect-item-content-item-toolbar {
display: flex;
justify-content: space-between;
position: absolute;
bottom: 12px;
left: 0;
width: 100%;
padding: 0 16px;
}

a.bber-reply {
cursor: pointer;
}

/* 去除页面白色底框 */
body[data-type=collect] #page {
border: 0;
box-shadow: none !important;
padding: 0 !important;
background: 0 0 !important;
}

.collect h2 {
margin-bottom: 0;
}
.collect .collect-desc {
margin-bottom: 10px;
}
.collect .collect-list {
display: flex;
gap: 18px;
flex-wrap: wrap;
}

.collect_box .collect-div a {
padding: 0 !important;
position: absolute;
z-index: 1;
width: 100%;
height: 100%;
margin: -10px -10px;
border-bottom: none !important;
}

.collect a:hover {
display: none;
}

.collect .collect-list .collect_box {
--w: calc(100% / 6 - 15px);
width: var(--w);
display: flex;
justify-content: space-between;
flex-direction: column;
background-position: center;
background-size: cover;
border-radius: 12px;
position: relative;
overflow: hidden;
padding: 10px;
color: #fff;
transition: 0.5s;
cursor:pointer;
}
.collect .collect-list .collect_box::after {
content: '';
position: absolute;
height: 100%;
width: 100%;
left: 0;
top: 0;
background: rgba(0,0,0,0.3);
z-index: 0;
transition: 0.5s;
}
.collect .collect-list .collect_box:hover {
transform: translateY(-10px);
}
.collect .collect-list .collect_box:hover::after {
background: rgba(0,0,0,0.1);
}
.collect .collect-list .collect_box .collect_top {
display: flex;
z-index: 1;
align-items: center;
justify-content: space-between;
}
.collect .collect-list .collect_box .collect_content {
z-index: 1;
margin-top: 86%;
}

.collect .collect-list .collect_box .collect_content span {
display: block;
font-size: 18px;
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
[data-theme='dark'] .collect .collect-list .collect_box {
color: #ddd !important;
}
[data-theme='dark'] .collect .collect-list .collect_box:hover {
transform: translateY(-10px);
}
[data-theme='dark'] .collect .collect-list .collect_box:hover::after {
background: rgba(0,0,0,0.2);
}
[data-theme='dark'] .collect .collect-list .collect_box::after {
background: rgba(0,0,0,0.5);
}
@media screen and (max-width: 1100px) {
.collect .collect-list {
gap: 15px;
}
.collect .collect-list .collect_box {
--w: calc(20% - 12px);
}
}
@media screen and (max-width: 900px) {
.collect .collect-list {
gap: 16px;
}
.collect .collect-list .collect_box {
--w: calc(25% - 12px);
}
}
@media screen and (max-width: 768px) {
.collect .collect-list {
gap: 15px;
}
.collect .collect-list .collect_box {
--w: calc(100% / 3 - 10px);
}
}
@media screen and (max-width: 500px) {
.collect .collect-list {
gap: 16px;
}
.collect .collect-list .collect_box {
--w: calc(50% - 8px);
}
}


.hexo-collect-item {
/* border-bottom: none !important; */
background: var(--icemyst-card-bg);
border: var(--style-border);
box-shadow: var(--icemyst-shadow-border);
border-radius: 12px;
margin: 8px 0;
height: 160px;
min-height: 160px !important;
width: 49%;
overflow: hidden;
position: relative;
clear: both;
max-width: 100%;
padding: 10px 0;
border-bottom: 1px #ddd solid;
}





#hexo-collect-item3 {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}

.hexo-collect-item .hexo-collect-picture a {
padding: 0 !important;
}

.hexo-collect-item .hexo-collect-picture img {
margin: 0px !important;
height: 100% !important;
}

.hexo-collect-tabs {
display: none;
}

.hexo-collect-title a {
border-bottom: 0px !important;
}

.hexo-collect-title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.hexo-collect-title a:hover {
color: #f2b94b !important;
background: rgba(0,0,0,0) !important;
}

.hexo-collect-pagination {
margin: auto;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}



.hexo-collect-title {
font-weight: bold;
font-size: inherit;
line-height: 2;
}

.hexo-collect-title a {
padding: 0 !important;
}

.hexo-collect-info {
padding-left: 210px !important;
margin-right: 0.5rem;
}

.hexo-collect-meta {
font-size: 0.7rem !important;
color: var(--Jay-secondtext);
margin-top: 0.3rem;
line-height: 1.05;
}

.hexo-collect-comments {
line-height: 1.2;
margin-top: 0.5rem;
font-size: 0.8rem !important;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
}

.hexo-collect-picture {
height: 100%;
top: 0 !important;
padding: 10px 0 10px 10px;
}

.hexo-collect-picture a img {
border-radius: 8px !important;
height: auto;
width: auto\9;
width:100%;
overflow:hidden;
}

/* @media screen and (min-width: 1300px) {
.hexo-collect-item {
width: 32%;
}
} */

@media screen and (max-width: 768px) {
.hexo-collect-item {
width: 100%;
height: 100%;
}
}

.hexo-collect-picture {
position: absolute;
left: 0;
/* top: 10px; */
width: 200px;
}

/* .hexo-collect-info {
padding-left: 120px;
} */

.hexo-collect-meta {
font-size: 12px;
padding-right: 10px;
}

.hexo-collect-comments {
font-size: 12px;
}

增加辅助函数

[blogRoot]themes\butterfly\scripts\helpers\page.js的合适位置粘贴如下代码:

1
2
3
4
5
6
7
8
// 藏宝阁星星
hexo.extend.helper.register('toStar', function(num) {
let tmp = ''
for (let i = 0; i < Math.floor(num); i++) { tmp += '<i class="fa-solid fa-star"></i>' } // 整数部分加 实心星星
if (num - Math.floor(num) != 0) tmp += '<i class="fa-solid fa-star-half-alt"></i>' // 小数部分转成 半星
for (let i = 0; i < 5 - Math.ceil(num); i++) { tmp += '<i class="fa-regular fa-star"></i>' } // 不够5个补 空心星星
return tmp
})

新建collect.yml和games.yml文件

这里存放的内容根据你自己的情况增加,这里我加的都是我自己的方式。

创建collect.yml文件存放以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- class_name: 📺 动画
class_desc: #分类描述
link_list:
- name: 刀剑神域 ソードアート・オンライン
img: https://img2.doubanio.com/view/photo/s_ratio_poster/public/p2169290186.webp
link: https://movie.douban.com/subject/6869376/
score: 5
icon: fa-solid fa-film
tip: 动画
- name: 斩·赤红之瞳 アカメが斬る!
img: https://img2.doubanio.com/view/photo/s_ratio_poster/public/p2260245867.webp
link: https://movie.douban.com/subject/25815602/
score: 4
icon: fa-solid fa-film
tip: 动画

创建games.yml文件存放以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 电影推荐
# name:电影名称
# link:电影链接
# cover: 封面图,可以从豆瓣页面右键复制图片链接
# date_grade: 电影评分与观看日期 ★☆
# comment: 评论
- class_name: 游戏分享
class_desc: #分类描述
link_list:
- name: 飞鸟会长不肯认输
link: https://pan.baidu.com/s/1gvT54_O5J-gA_nYuOeWjLg?pwd=igst
cover: https://jsd.onmicrosoft.cn/npm/blogimages/games/f6d362b9aea9_720w.png
date_grade: PC硬盘
comment: 海豹社于2022年12月23日发售的短篇Galgame,由若叶祥庆负责剧本,濑奈茅冬等负责原画。游戏的原画精美,剧本短小精悍,以恋爱发糖为主
- name: 野良与皇女与流浪猫之心
link: https://pan.baidu.com/s/1Wn8AgENpFspxi8ke0K4DiA?pwd=pxwd
cover: https://jsd.onmicrosoft.cn/npm/blogimages/games/47cb5fa1440w.jpg
date_grade: kr、PC硬盘
comment: 开发商HARUKAZE发售的一部以欢乐搞笑为基调的美少女游戏,有些毒点
- name: 怪物猎人:世界
link: https://www.xiaoheihe.cn/games/detail/582010
cover: https://cdn.max-c.com/heybox/dailynews/img/94376ca41326836587a137d5999733e5.jpg
date_grade: CAPCOM Co., Ltd.
comment: 新的生命之地。

到这里hexo cl && heox g && hexo s三连看效果即可。