Skip to content

Commit f64e087

Browse files
committed
优化图片样式,添加图片和字体预加载
1 parent 4383e81 commit f64e087

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/layouts/BaseLayout.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const { description, keywords, title } = Astro.props;
1212
<meta charset="utf-8" />
1313
<link rel="icon" href="/favicon.svg" type="image/svg" />
1414
<link rel="sitemap" href="/sitemap-index.xml" />
15+
<link rel="preload" href="/fonts/MapleMono-Regular.woff2" as="font" type="font/woff2" crossorigin>
16+
<link rel="preload" href="/assets/images/chair.webp" as="image" type="image/webp" crossorigin>
1517
<script src="../scripts/swUnregister.ts"></script>
1618
<ClientRouter />
1719
<meta name="viewport" content="width=device-width, initial-scale=1" />

src/posts/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ title: index
1212

1313
累了吗,可以在下面的椅子上休息,坐多久都可以!
1414

15-
![chair](../../public/assets/images/chair.webp "看起来很结实的椅子")
15+
![chair](/assets/images/chair.webp "看起来很结实的椅子")

src/styles/global.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ a {
4747

4848
@font-face {
4949
font-family: "Maple Mono";
50-
src: url("../../public/fonts/MapleMono-Regular.woff2") format("woff");
50+
src: url("/fonts/MapleMono-Regular.woff2") format("woff2");
5151
font-weight: normal;
5252
font-style: normal;
5353
font-display: swap;

src/styles/markdown.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@
3636
font-size: 0.9rem;
3737
}
3838

39+
img,
40+
video {
41+
width: 100%;
42+
object-fit: cover;
43+
background-color: #f8f9fa;
44+
border-radius: 8px;
45+
}
46+
47+
video {
48+
outline: none; /* 移除焦点时的边框 */
49+
cursor: pointer; /* 鼠标悬停时显示手型 */
50+
}
51+
3952
@media (max-width: 768px) {
4053
line-height: 1.4;
4154
code {

0 commit comments

Comments
 (0)