友链魔改美化

本次美化设计来自 @小植同学 请大家在食用前点击下方链接, 支持下设计者 🎉🎉🎉

1.效果图

2.添加页面结构

themes/anzhiyu/layout/includes/page/flink.pug 中添加如下代码

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
              else
img.cf-friends-avatar.no-lightbox(src=url_for(item.avatar) cf-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt='cover' )
span.flink-sitename.cf-friends-name= item.name
//- --------以下为新增代码-----------
else if i.flink_style === 'supercard'
.links-friends
each item in i.link_list
.friends-item
.player
- var level = item.level || 'v1'
.player-content-v1(class= level === 'v2' ? 'player-content-v2' : level === 'v3' ? 'player-content-v3' : '')
if item.alias
span(class= level === 'v1' ? 'alias-v1' : level === 'v2' ? 'alias-v2' : level === 'v3' ? 'alias-v3' :'')
span
if item.level === 'v1'
a(href=url_for(theme.friends_vip.alias.v1), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.alias.v1))
img(src=url_for(theme.friends_vip.alias.v1), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, style="width: 12px", onclick="return false;", data-ll-status="loaded", class="entered loaded")
else if item.level === 'v2'
a(href=url_for(theme.friends_vip.alias.v2), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.alias.v2))
img(src=url_for(theme.friends_vip.alias.v2), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, data-lazy-src=url_for(theme.friends_vip.alias.v2), style="width: 12px", onclick="return false;", data-ll-status="loaded", class="entered loaded")
else if item.level === 'v3'
a(href=url_for(theme.friends_vip.alias.v3), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.alias.v3))
img(src=url_for(theme.friends_vip.alias.v3), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, data-lazy-src=url_for(theme.friends_vip.alias.v3), style="width: 12px", onclick="return false;", data-ll-status="loaded", class="entered loaded")
= item.alias
if item.buoy === true
.player-bg
if item.level === 'v1'
a(href=url_for(theme.friends_vip.buoy.v1), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.buoy.v1))
img(src=url_for(theme.friends_vip.buoy.v1), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, data-lazy-src=url_for(theme.friends_vip.buoy.v1), data-ll-status="loaded", class="entered loaded")
else if item.level === 'v2'
a(href=url_for(theme.friends_vip.buoy.v2), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.buoy.v2))
img(src=url_for(theme.friends_vip.buoy.v2), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, data-lazy-src=url_for(theme.friends_vip.buoy.v2), data-ll-status="loaded", class="entered loaded")
else if item.level === 'v3'
a(href=url_for(theme.friends_vip.buoy.v3), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.buoy.v3))
img(src=url_for(theme.friends_vip.buoy.v3), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, data-lazy-src=url_for(theme.friends_vip.buoy.v3), data-ll-status="loaded", class="entered loaded")
.album-cover(class= level=== 'v1'? 'album-cover-v1' : level === 'v2' ? 'album-cover-v2' : level === 'v3' ? 'album-cover-v3' : '')
a(href=url_for(item.link), title=url_for(item.name), target="_blank", draggable="false")
img.cf-friends-avatar.no-lightbox.entered.loaded(data-lazy-src=url_for(item.avatar), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, alt=url_for(item.name), draggable="false", data-ll-status="loaded", src=url_for(item.avatar))
if item.buoy === true
if item.level === 'v1'
a(href=url_for(theme.friends_vip.symbol.v1), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.symbol.v1))
img.ava-badge.entered.loaded(src=url_for(theme.friends_vip.symbol.v1), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, data-lazy-src=url_for(theme.friends_vip.symbol.v1), data-ll-status="loaded")
else if item.level === 'v2'
a(href=url_for(theme.friends_vip.symbol.v2), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.symbol.v2))
img.ava-badge.entered.loaded(src=url_for(theme.friends_vip.symbol.v2), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, data-lazy-src=url_for(theme.friends_vip.symbol.v2), data-ll-status="loaded")
else if item.level === 'v3'
a(href=url_for(theme.friends_vip.symbol.v3), data-fancybox="gallery", data-caption="", data-thumb=url_for(theme.friends_vip.symbol.v3))
img.ava-badge.entered.loaded(src=url_for(theme.friends_vip.symbol.v3), onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'`, data-lazy-src=url_for(theme.friends_vip.symbol.v3), data-ll-status="loaded")
.play-controls-name
a(href=url_for(item.link), target="_blank", draggable="false")
h4.ui.header.one-line.f-w-name-hg-1(class=level=== 'v1' ? 'f-w-name-ph' : level === 'v2' ? 'f-w-name-zx' : level === 'v3' ? 'f-w-name-pv' : '', title=url_for(item.name))= item.name
.play-controls-time
- var date = new Date(item.add_time)
- var formattedDate = date.toISOString().split('T')[0]
p.one-line(class=level=== 'v1' ? 'f-w-name-ph' : level === 'v2' ? 'f-w-name-zx' : level === 'v3' ? 'f-w-name-pv' : '')= formattedDate +' 加入本站'
.play-controls-introduction
p.one-line(class=level=== 'v1' ? 'f-w-name-ph' : level === 'v2' ? 'f-w-name-zx' : level === 'v3' ? 'f-w-name-pv' : '')(title=url_for(item.descr))= item.descr
//- -----------以上为新增代码-----------
!= page.content

3.添加样式代码

我添加样式的方式
  • themes/anzhiyu/source/css/_custom/ 中创建 friends-supercard.css 文件;
    • _custom 目录是自建的, 名字可以随意起
  • themes/anzhiyu/source/css/index.styl 添加如下代码
    • 添加以下代码后, 构建时会自动引入 _custom 目录下的所有 css 文件, 不需要在主题配置文件中手动引入
1
@import '_custom/*.css'

和其他自定义样式代码的添加方式一样, 在 source/css/ 中创建 friends-supercard.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
#article-container .links-friends {
margin-top: 1em;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
-webkit-column-gap: 10px;
-moz-column-gap: 10px;
column-gap: 10px;
min-width: 240px;
}

#article-container .links-friends .friends-item {
margin: 2px 0;
display: -webkit-box;
display: -moz-box;
display: -webkit-flex;
display: -ms-flexbox;
display: box;
display: flex;
-webkit-box-pack: distribute;
-moz-box-pack: distribute;
-o-box-pack: distribute;
-ms-flex-pack: distribute;
-webkit-justify-content: space-around;
justify-content: space-around;
-webkit-box-align: center;
-moz-box-align: center;
-o-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
height: calc(320px / 2 - 6px);
}

#article-container .links-friends .friends-item .player {
position: relative;
z-index: 3;
width: 100%;
height: 130px;
border-radius: 8px;
}

#article-container .links-friends .friends-item .player .player-content-v1 {
background: linear-gradient(25deg, #000 10%, #383838 70%, #000 100%);
position: relative;
height: 100%;
border-radius: 8px;
z-index: 2;
}

#article-container .links-friends .friends-item .player .player-content-v3 {
background: linear-gradient(
335deg,
#1b8fda 10%,
#6fc7e5 70%,
#8bc8ef 100%
) !important;
}

#article-container .links-friends .friends-item .player .player-content-v2 {
background: linear-gradient(317deg, #a14fd2, #8888fc 30%, #c6bcff) !important;
}

#article-container
.links-friends
.friends-item
.player
.player-content-v1:before {
transition: background-position 0.5s;
}

#article-container
.links-friends
.friends-item
.player
.player-content-v1:before {
content: "";
background-image: url(/img/link/black-line.svg);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
width: 100%;
height: 100%;
position: absolute;
border-radius: 8px;
}

#article-container
.links-friends
.friends-item
.player
.player-content-v2:before {
background-image: url(/img/link/purple-line.svg) !important;
}

#article-container
.links-friends
.friends-item
.player
.player-content-v3:before {
background-image: url(/img/link/blue-line.svg) !important;
}

.alias-v1 {
position: absolute;
padding: 0 4px;
background: linear-gradient(to right, #1a2a6c, #b21f1f, #fdbb2d);
color: #fff;
border-radius: 8px 0 8px 0;
font-size: 12px;
line-height: 1.7em;
}

.alias-v2 {
position: absolute;
padding: 0 4px;
background: linear-gradient(to right, rgb(217 48 83), rgb(150 89 205));
color: #efefef !important;
border-radius: 8px 0 8px 0;
font-size: 12px;
line-height: 1.7em;
}

.alias-v3 {
position: absolute;
padding: 0 4px;
background: linear-gradient(to right, rgb(67, 206, 162), rgb(24, 90, 157));
color: #efefef !important;
border-radius: 8px 0 8px 0;
font-size: 12px;
line-height: 1.7em;
}

.alias-v1 a,
.alias-v2 a,
.alias-v3 a {
pointer-events: none;
}
.friends-item a {
color: #4183c4;
text-decoration: none;
}
.links-friends a {
text-decoration: none !important;
}

#article-container .links-friends a {
text-decoration: none !important;
padding: 0 !important;
}

#article-container .links-friends img {
margin: 0 4px 0 0 !important;
cursor: default;
pointer-events: none;
box-shadow: rgba(0, 0, 0, 0) 0px 5px 15px;
border-style: none;
}

#article-container img {
max-width: 100%;
transition: 0.3s;
border-radius: 8px;
}
#article-container img {
object-fit: cover;
max-height: 900px;
}
.alias-v1 img,
.alias-v2 img,
.alias-v3 img {
display: inline-block !important;
}

.player-bg {
position: absolute;
top: -14px;
right: -2px;
z-index: -1;
}

.player-bg {
transform-style: preserve-3d;
transition: transform 1.8s;
}

.player-bg img {
width: 110px;
height: auto;
}

.album-cover-v1 {
box-shadow: 0 0 0 1px #ffd38b;
}

.album-cover {
width: 52px;
height: 52px;
border-radius: 50%;
position: absolute;
top: 26px;
left: 10px;
overflow: hidden;
transition: 0.3s ease;
}

.album-cover-v2 {
box-shadow: 0 0 0 1px #7d49d4;
}

.album-cover-v3 {
box-shadow: 0 0 0 1px #146792;
}

.album-cover img {
display: block;
position: absolute;
top: 0;
width: 100%;
height: 100%;
object-fit: cover;
padding: 4px;
border-radius: 50% !important;
}

#article-container
a:not([data-fancybox="gallery"]):not(.headerlink):not(.cf-friends-link):not(
.tag-Link
):not(.btn-anzhiyu):not(.no-text-decoration) {
font-weight: 500;
border-bottom: solid 2px var(--anzhiyu-lighttext);
color: var(--anzhiyu-fontcolor);
padding: 0 0.2em;
text-decoration: none;
font-family: auto;
}

.ava-badge {
position: absolute;
left: 46px;
top: 56px;
width: 16px;
}

.play-controls-name {
position: absolute;
top: 0;
left: 68px;
width: calc(100% - 178px);
}

#article-container
a:not([data-fancybox="gallery"]):not(.headerlink):not(.cf-friends-link):not(
.tag-Link
):not(.btn-anzhiyu):not(.no-text-decoration) {
font-weight: 500;
border-bottom: solid 2px var(--anzhiyu-lighttext);
color: var(--anzhiyu-fontcolor);
padding: 0 0.2em;
text-decoration: none;
font-family: auto;
}

.one-line {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
.f-w-name-ph {
color: #f2cb69 !important;
transition: 0.2s;
}

.f-w-name-zx {
color: #5657ba !important;
transition: 0.2s;
}

.f-w-name-pv {
color: #004a96 !important;
transition: 0.2s;
}

.ui,
.header {
border: none;
margin: calc(2rem - 0.14285714em) 0 1rem;
padding: 0 0;
font-family: Lato, "Helvetica Neue", Arial, Helvetica, sans-serif;
font-weight: 700;
line-height: 1.28571429em;
text-transform: none;
}

.play-controls-time {
position: absolute;
font-size: 0.875rem;
top: 56px;
left: 68px;
}

#article-container .links-friends p {
cursor: default;
}

#article-container p {
margin: 0 0 16px;
}
.one-line {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
.f-w-name-ph {
color: #f2cb69 !important;
transition: 0.2s;
}

.play-controls-introduction {
position: absolute;
top: 92px;
margin: 0 14px;
max-width: calc(100% - 28px);
}

#article-container .links-friends p {
cursor: default;
}

#article-container p {
margin: 0 0 16px;
}
.one-line {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
.f-w-name-ph {
color: #f2cb69 !important;
transition: 0.2s;
}

.friends-item:hover {
transform: scale(1.02);
}
#article-container .links-friends *:hover {
cursor: pointer;
}
#article-container
.links-friends
.friends-item:hover
.player
.player-content-v1:before {
background-position: 100% 50%;
}

.friends-item:hover .player-bg {
transform: rotateY(360deg);
}

在主题配置文件(_config.anzhiyu.yml)中添加如下代码即可

1
2
3
4
inject:
head:
# 以下为新增代码
- <script src="/css/friends-supercard.css"></script> # 友链美化样式

4.配置项

_config.anzhiyu.yml 中配置以下内容

  • alias: 控制左上角的图片
  • buoy: 控制右上角的大图
  • symbol: 控制头像右下角的图片
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 友链配置-vip
friends_vip:
alias:
v1: /img/link/alias_v1.png
v2: /img/link/alias_v2.png
v3:
buoy:
v1: /img/link/buoy_v1.png
v2: /img/link/buoy_v2.png
v3:
symbol:
v1: /img/link/symbol_v1.png
v2: /img/link/symbol_v2.png
v3:

说明: 没有素材了, v3就没有设置

5.数据添加

source/_data/link.yml 中添加友链数据

1
2
3
4
5
6
7
8
9
- name: 小植同学
link: https://blog.xiaoztx.top
avatar: https://blog.xiaoztx.top/img/xiaozhi.jpg
siteshot: https://img.xiaoztx.top/image/2023/10/29/9d2fa78857f43f0250a0776fd6d02b6c.jpeg
descr: 锦鲤相随,好运常伴
alias: 小植
level: v1
buoy: true
add_time: 2023-08-01

说明

6.大功告成 🚬🚬🚬

7.素材篇, 需要的自行右键下载

素材存放在 source/img/link 文件夹下