Skip to content

Commit c5bb499

Browse files
committed
更新友链页面
1 parent 2febfd2 commit c5bb499

File tree

3 files changed

+80
-81
lines changed

3 files changed

+80
-81
lines changed

public/assets/friends.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"name": "Keritial",
4+
"des": "一个平淡的个体.",
5+
"icon": "https://avatars.githubusercontent.com/u/50075277?v=4",
6+
"url": "https://krtl.top"
7+
},
8+
{
9+
"name": "Shikochin",
10+
"des": "自愚可悖的庸人。",
11+
"icon": "https://avatars.githubusercontent.com/u/60309542?v=4",
12+
"url": "https://shikoch.in/"
13+
}
14+
]

src/components/FriendCard.astro

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/pages/friend-links.astro

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,75 @@
11
---
2-
import FriendCard from "../components/FriendCard.astro";
2+
import { Image } from "astro:assets";
33
import FriendsLayout from "../layouts/FriendsLayout.astro";
4+
import friends from "../../public/assets/friends.json";
5+
friends.sort(() => Math.random() - 0.5);
46
---
57

68
<FriendsLayout
79
description="本页面供奉着我的朋友们(不是"
810
keywords="friends,links"
911
>
10-
<FriendCard
11-
name="Keritial"
12-
description="一个平淡的个体."
13-
icon="https://avatars.githubusercontent.com/u/50075277?v=4"
14-
url="https://krtl.top"
15-
/>
16-
<FriendCard
17-
name="Shikochin"
18-
description="自愚可悖的庸人。"
19-
icon="https://avatars.githubusercontent.com/u/60309542?v=4"
20-
url="https://shikoch.in/"
21-
>
22-
</FriendCard>
12+
{
13+
friends.map(({ name, des, icon, url }) => (
14+
<a class="main" href={url}>
15+
<div class="left">
16+
<Image src={icon} alt={name + " avatar"} width="96" height="96" />
17+
</div>
18+
<div class="right">
19+
<p class="name">{name}</p>
20+
<p class="description">{des}</p>
21+
</div>
22+
</a>
23+
))
24+
}
2325
</FriendsLayout>
26+
27+
<style>
28+
.main {
29+
text-decoration: none; /* 去除下划线 */
30+
color: inherit; /* 继承父元素的颜色 */
31+
margin: 0 1rem 1.5rem 1rem;
32+
display: flex;
33+
align-items: center;
34+
justify-content: space-around;
35+
height: 8rem;
36+
width: auto;
37+
background-color: white;
38+
border: 1px solid #f4f4f5; /* 添加黑色的边框,宽度为 2px */
39+
border-radius: 1rem;
40+
padding: 6%;
41+
}
42+
43+
@media (max-width: 320px) {
44+
.left {
45+
display: none;
46+
}
47+
}
48+
.main:hover {
49+
border: 1px solid #00d7c0; /* 添加黑色的边框,宽度为 2px */
50+
/* background-color: #f4f3f6; */
51+
/* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); */
52+
}
53+
54+
.name {
55+
font-size: 1.2rem;
56+
white-space: nowrap;
57+
overflow: hidden; /* 超出隐藏 */
58+
text-overflow: ellipsis; /* 超出显示省略号 */
59+
width: 100%; /* 超出显示省略必须有明确的宽度 */
60+
}
61+
62+
.description {
63+
font-weight: lighter;
64+
font-size: 1rem;
65+
color: #808080;
66+
white-space: nowrap;
67+
overflow: hidden; /* 超出隐藏 */
68+
text-overflow: ellipsis; /* 超出显示省略号 */
69+
width: 100%; /* 超出显示省略必须有明确的宽度 */
70+
}
71+
72+
img {
73+
border-radius: 90px;
74+
}
75+
</style>

0 commit comments

Comments
 (0)