Skip to content

Commit 6f017ca

Browse files
committed
merge: merge PR #2 from keritial
1 parent 81462f9 commit 6f017ca

13 files changed

Lines changed: 81 additions & 53 deletions

src/components/FriendCard.astro

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ const { name, url, description, icon } = Astro.props;
77

88
<a class="main" href={url}>
99
<div class="left">
10-
<Image
11-
src={icon}
12-
alt="descriptive text"
13-
width="128"
14-
height="128"
15-
/>
10+
<Image src={icon} alt="descriptive text" width="96" height="96" />
1611
</div>
1712
<div class="right">
1813
<p class="name">{name}</p>
@@ -28,29 +23,35 @@ const { name, url, description, icon } = Astro.props;
2823
display: flex;
2924
align-items: center;
3025
justify-content: space-around;
31-
width: 23rem;
32-
height: 10rem;
33-
26+
height: 8rem;
27+
width: auto;
3428
background-color: white;
3529
border: 1px solid black; /* 添加黑色的边框,宽度为 2px */
36-
border-radius: 2.9rem;
30+
border-radius: 1rem;
31+
padding: 6%;
32+
}
33+
34+
@media (max-width: 320px) {
35+
.left{
36+
display: none;
37+
}
3738
}
38-
.main:hover{
39+
.main:hover {
3940
background-color: #f4f3f6;
4041
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
4142
}
4243

43-
.name{
44-
font-size: 1.5rem;
44+
.name {
45+
font-size: 1.2rem;
4546
white-space: nowrap;
4647
overflow: hidden; /* 超出隐藏 */
4748
text-overflow: ellipsis; /* 超出显示省略号 */
4849
width: 100%; /* 超出显示省略必须有明确的宽度 */
4950
}
50-
51-
.description{
51+
52+
.description {
5253
font-weight: lighter;
53-
font-size: 1.2rem;
54+
font-size: 1rem;
5455
color: #808080;
5556
white-space: nowrap;
5657
overflow: hidden; /* 超出隐藏 */

src/components/HeadMenu.astro

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@
2626
</script>
2727

2828
<style>
29-
@media (max-width: 50rem) {
30-
}
31-
3229
.menu {
3330
display: flex;
3431
align-items: center;
3532
justify-content: space-around;
3633
height: 3.5rem;
3734
width: 38rem;
38-
max-width: 100dvw;
35+
/* max-width: 100dvw;
3936
overflow-x: auto;
40-
overflow-y: hidden;
37+
overflow-y: hidden; */
4138
background-color: rgba(255, 255, 255, 0.1);
4239
backdrop-filter: blur(4px);
4340
border: 1px solid rgba(0, 0, 0, 0.2); /* 添加黑色的边框,宽度为 2px */
@@ -54,7 +51,7 @@
5451
transition:
5552
background-color 0.2s ease-in-out,
5653
color 0.2s ease-in-out;
57-
flex-shrink: 0;
54+
/* flex-shrink: 0; */
5855
}
5956

6057
.menu > a:hover {

src/components/TitileCard.astro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const { title, date, wordNum } = Astro.props;
3333
gap: 0.7rem; /* 行间距 */
3434
align-items: center;
3535
max-width: 90vw;
36-
min-width: 32vw;
3736
height: 8rem;
3837
margin: 20px 20px 10px 20px;
3938
border: 1px solid rgba(0, 0, 0, 0.2); /* 添加黑色的边框,宽度为 2px */

src/layouts/BaseLayout.astro

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const { description, keywords ,selected} = Astro.props;
1616
<meta name="description" content={description} />
1717
<meta name="keywords" content={keywords} />
1818
<meta name="author" content="LingLambda" />
19+
<!-- 统一不同浏览器的默认样式 -->
1920
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha512-NhSC1YmyruXifcj/KFRWoC561YpHpc5Jtzgvbuzx5VozKpWvQ+4nXhPdFgmx8xqexRcpAglTj9sIBWINXa8x5w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
2021
<title>Ling的小窝</title>
2122
</head>
@@ -25,9 +26,7 @@ const { description, keywords ,selected} = Astro.props;
2526
<HeadMenu/>
2627
</header>
2728
<main>
28-
<section>
29-
<slot />
30-
</section>
29+
<slot />
3130
</main>
3231
<!-- <hr style="width:600px;color:#808080; margin-top: 1rem;" /> -->
3332
<footer>
@@ -84,7 +83,7 @@ const { description, keywords ,selected} = Astro.props;
8483
}
8584

8685
#container {
87-
height: fit-content;
86+
height: fit-content; /*限制最大高度不超过父容器*/
8887
min-height: 100%;
8988
display: flex;
9089
flex-direction: column;
@@ -117,7 +116,7 @@ const { description, keywords ,selected} = Astro.props;
117116
flex-direction: row;
118117
justify-content: center;
119118
padding: 1rem;
120-
flex-wrap: wrap;
119+
flex-wrap: wrap; /*允许换行*/
121120
}
122121

123122
footer > * {
@@ -132,7 +131,4 @@ const { description, keywords ,selected} = Astro.props;
132131
max-width: 36rem;
133132
}
134133

135-
section {
136-
padding: 8%;
137-
}
138134
</style>

src/layouts/BlogLayout.astro

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
import BaseLayout from "./BaseLayout.astro";
3+
4+
5+
---
6+
<BaseLayout>
7+
<section>
8+
<slot />
9+
</section>
10+
</BaseLayout>
11+
12+
<style>
13+
14+
section {
15+
padding: 0 8% 0 8%;
16+
/* padding:8% */
17+
}
18+
</style>

src/layouts/FriendsLayout.astro

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ import BaseLayout from "./BaseLayout.astro";
1010

1111
<style>
1212
#cards {
13-
/* display: grid;
14-
grid: auto-flow auto / repeat(2, auto); */
15-
display: flex;
16-
flex-wrap: wrap;
13+
display: grid;
14+
grid-template-columns: repeat(2, 300px); /* 每张卡片固定宽度 */
15+
justify-content: center; /* 整体网格居中 */
16+
gap: 20px;
17+
}
18+
@media (max-width: 600px) {
19+
#cards {
20+
grid-template-columns: 1fr; /* 在小屏幕上改为单列 */
21+
width: 90vw;
22+
}
1723
}
1824
</style>

src/layouts/MainLayout.astro

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
import BaseLayout from "./BaseLayout.astro";
3+
4+
5+
---
6+
<BaseLayout>
7+
<slot />
8+
</BaseLayout>
9+
10+
<style>
11+
</style>

src/pages/about.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
import BaseLayout from "../layouts/BaseLayout.astro";
2+
import MainLayout from "../layouts/MainLayout.astro";
33
import Prose from "../components/Prose.astro";
44
import { Content } from "../posts/about.md";
55
---
66

7-
<BaseLayout description='本页面记录了关于我的信息' keywords="关于,Ling,LingLambda">
7+
<MainLayout description='本页面记录了关于我的信息' keywords="关于,Ling,LingLambda">
88
<Prose>
99
<Content />
1010
</Prose>
11-
</BaseLayout>
11+
</MainLayout>

src/pages/blog.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
import BaseLayout from "../layouts/BaseLayout.astro";
32
import TitleCard from "../components/TitileCard.astro";
43
import { getCollectionOrderByDate, getWordCount } from "../utils/utils.ts";
4+
import MainLayout from "../layouts/MainLayout.astro";
55
const blogs = await getCollectionOrderByDate("blog", ({ data }) => {
66
return data.published === true;
77
});
88
---
99

10-
<BaseLayout description='本页面列出了所有blog页面' keywords="blog">
10+
<MainLayout description='本页面列出了所有blog页面' keywords="blog">
1111
{
1212
blogs.map(async (blog) => {
1313
const { title, date, description } = blog.data;
@@ -19,7 +19,7 @@ const blogs = await getCollectionOrderByDate("blog", ({ data }) => {
1919
);
2020
})
2121
}
22-
</BaseLayout>
22+
</MainLayout>
2323

2424
<style>
2525
</style>

src/pages/blog/[page].astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
import { render } from "astro:content";
3-
import BaseLayout from "../../layouts/BaseLayout.astro";
43
import Prose from "../../components/Prose.astro";
54
import {
65
getCollectionOrderByDate,
76
getWordCount,
87
titleToPinyin,
98
} from "../../utils/utils";
9+
import BlogLayout from "../../layouts/BlogLayout.astro";
1010
1111
export const getStaticPaths = async () => {
1212
const blogs = await getCollectionOrderByDate("blog", ({ data }) => {
@@ -40,7 +40,7 @@ const MIN_READ_COUNT = 350;
4040
const readTimeMin = Math.ceil(fontNum / MIN_READ_COUNT);
4141
---
4242

43-
<BaseLayout description={description} keywords={tags}>
43+
<BlogLayout description={description} keywords={tags}>
4444
<div class="blog-head">
4545
<h1 class="title">{title}</h1>
4646
<p class="description">{description}</p>
@@ -69,7 +69,7 @@ const readTimeMin = Math.ceil(fontNum / MIN_READ_COUNT);
6969
data-lang="zh-CN"
7070
crossorigin="anonymous"
7171
async></script>
72-
</BaseLayout>
72+
</BlogLayout>
7373

7474
<style>
7575
em {

0 commit comments

Comments
 (0)