|
1 | 1 | --- |
2 | | -import FriendCard from "../components/FriendCard.astro"; |
| 2 | +import { Image } from "astro:assets"; |
3 | 3 | import FriendsLayout from "../layouts/FriendsLayout.astro"; |
| 4 | +import friends from "../../public/assets/friends.json"; |
| 5 | +friends.sort(() => Math.random() - 0.5); |
4 | 6 | --- |
5 | 7 |
|
6 | 8 | <FriendsLayout |
7 | 9 | description="本页面供奉着我的朋友们(不是" |
8 | 10 | keywords="friends,links" |
9 | 11 | > |
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 | + } |
23 | 25 | </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