1. 前言

这个侧边栏的灵感来源于Ethan.Tzy

本来想按照他的方法配置侧边栏,但是发现还需要P图,因此本人魔改了另外一个版本,这个版本不需要P图,效果如下所示:
正面
alt text

2. 配置card_wechat.pug

首先在themes\butterfly\layout\includes\widget中,创建文件card_wechat.pug,然后在文件中输入以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
.card-container
.card-wechat
// 正面
.card-face.card-front
.front-left
img(src="http://img.ldyer.top/img/%E5%BE%AE%E4%BF%A1icon.png" alt="微信图标")
.front-right
p 翻转卡片~
p 查看我的联系方式
// 背面
.card-face.card-back
.back-left
p 如有事情
p 请扫一扫🔎
p 添加微信好友
.back-center
img(src="http://img.ldyer.top/img/%E5%BE%AE%E4%BF%A1%E4%BA%8C%E7%BB%B4%E7%A0%81.png" alt="二维码")

将上述两个图片链接更改为你的链接,第一个是微信图标,第二个是你的微信二维码。

3. 配置index.pug

打开相同目录themes\butterfly\layout\includes\widget下的index.pug文件,在里面加入该条代码:

1
!=partial('includes/widget/card_wechat', {}, {cache: true})

所加的位置如图所示:

alt text

4. css渲染

引入它的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
.card-wechat {
height: 120px;
position: relative;
transform-style: preserve-3d;
transition: transform 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
cursor: pointer;
margin-bottom: 20px;
}

/* 鼠标悬停翻转 */
.card-container:hover .card-wechat {
transform: rotateY(180deg);
}

.card-face {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 10px;
box-shadow: 0 8px 16px rgba(0,0,0,0.15);
display: flex;
overflow: hidden;
}

/* 正面 */
.card-front {
background: linear-gradient(135deg, #caeacaec, #cfe1cfe9);
color: #fff;
backdrop-filter: blur(5px);
}

.front-left, .front-right {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 0 10px;
box-sizing: border-box;
}
.front-left {
width: 30%;
position: relative;
}
.front-left::after {
content: "";
position: absolute;
right: 0; /* 贴在右边界 */
top: 25%; /* 顶部距离父容器高度的25% */
height: 50%; /* 占父容器高度的50% */
width: 2px; /* 线的宽度 */
background-color: rgba(0, 0, 0, 0.5); /* 半透明白色 */
}

.front-left img {
width: 60px;
height: 60px;
margin-bottom: 2px;
}

.front-left span {
font-size: 25px;
font-weight: bold;
}

.front-right {
margin-left: 5px;
font-size: 120%;
align-items: flex-start; /* 左对齐 */
}

.front-right p {
color: #000;
margin: 0;
font-size: 120%;
line-height: 1.5;
}

/* 背面 */
.card-back {
background-color: #ffffffe7;
backdrop-filter: blur(2px);
color: #333;
transform: rotateY(180deg);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 15px;
box-sizing: border-box;
}

/* 左右布局 */
.back-left {
width: 50%;
display: flex;
flex-direction: column;
justify-content: center; /* 垂直居中 */
text-align: center;
align-items: center;
font-size: 150%;
color: #000000;
}

/* 左侧两行文字紧密排列 */
.back-left p {
margin: 0; /* 去掉默认上下 margin */
line-height: 1; /* 行高紧凑,保证文字贴近 */
padding: 0;
}

.back-center, .back-right {
display: flex;
justify-content: center;
align-items: center;
}

.back-center img {
width: 100px;
height: 100px;
border-radius: 8px;
}