Skip to content

Commit 04bfb66

Browse files
committed
重构 friendlinks 布局
1 parent a985712 commit 04bfb66

File tree

2 files changed

+50
-59
lines changed

2 files changed

+50
-59
lines changed

src/layouts/FriendsLayout.astro

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

src/pages/friend-links.astro

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,61 @@
11
---
22
import { Image } from "astro:assets";
3-
import FriendsLayout from "../layouts/FriendsLayout.astro";
43
import friends from "../../public/assets/friends.json";
4+
import MainLayout from "../layouts/MainLayout.astro";
55
friends.sort(() => Math.random() - 0.5);
66
---
77

8-
<FriendsLayout>
9-
{
10-
friends.map(({ name, des, icon, url }) => (
11-
<a class="main" href={url}>
12-
<div class="left">
13-
<Image src={icon} alt={name + " avatar"} width="96" height="96" />
14-
</div>
15-
<div class="right">
16-
<p class="name">{name}</p>
17-
<p class="description">{des}</p>
18-
</div>
19-
</a>
20-
))
21-
}
22-
</FriendsLayout>
8+
<MainLayout description="本页面供奉着我的朋友们(不是" keywords="friends,links">
9+
<div id="cards">
10+
{
11+
friends.map(({ name, des, icon, url }) => (
12+
<a class="main" href={url}>
13+
<div class="left">
14+
<Image src={icon} alt={name + " avatar"} width="96" height="96" />
15+
</div>
16+
<div class="right">
17+
<p class="name">{name}</p>
18+
<p class="description">{des}</p>
19+
</div>
20+
</a>
21+
))
22+
}
23+
</div>
24+
25+
<div id="info">
26+
<p>前辈!和我交换友链吧!</p>
27+
<p>
28+
提供你的 <strong>名字</strong>、<strong>描述</strong>、<strong
29+
>头像</strong
30+
>、<strong>地址</strong>, 或者按照如下格式发送到
31+
<a href="mailto:[email protected]" target="_blank">这里!</a>
32+
</p>
33+
<pre><code>
34+
"name": "田所浩二",
35+
"des": "逸一时误一世。",
36+
"icon": "https://icon.shimo/114514",
37+
"url": "https://tadokorokouji.homo"
38+
</code></pre>
39+
</div>
40+
</MainLayout>
2341

2442
<style>
43+
#info {
44+
padding: 20px 50px;
45+
}
46+
#cards {
47+
display: grid;
48+
grid-template-columns: repeat(2, 300px); /* 每张卡片固定宽度 */
49+
justify-content: center; /* 整体网格居中 */
50+
gap: 20px;
51+
}
52+
@media (max-width: 600px) {
53+
#cards {
54+
grid-template-columns: 1fr; /* 在小屏幕上改为单列 */
55+
width: 90vw;
56+
}
57+
}
58+
2559
.main {
2660
text-decoration: none; /* 去除下划线 */
2761
color: inherit; /* 继承父元素的颜色 */

0 commit comments

Comments
 (0)