From 60131d6fa9cb0a948aea8c14c59c7f76eff11b0f Mon Sep 17 00:00:00 2001 From: xy <10816187@qq.com> Date: Wed, 12 Aug 2026 18:15:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9B=BE=E7=89=87lazy=20loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AspectRatio.astro | 0 src/components/LazyImage.astro | 131 +++++++++++++++++++++++++++++++ src/components/PostList.astro | 9 +-- src/pages/index.astro | 2 +- src/pages/page/[...page].astro | 2 +- 5 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 src/components/AspectRatio.astro create mode 100644 src/components/LazyImage.astro diff --git a/src/components/AspectRatio.astro b/src/components/AspectRatio.astro new file mode 100644 index 0000000..e69de29 diff --git a/src/components/LazyImage.astro b/src/components/LazyImage.astro new file mode 100644 index 0000000..8ec026b --- /dev/null +++ b/src/components/LazyImage.astro @@ -0,0 +1,131 @@ +--- +interface Props { + src: string; + alt?: string; + width?: number; + height?: number; + class?: string; +} + +const { + src, + alt = "", + width, + height, + class: className = "" +} = Astro.props; +--- + +
+
+ + {alt} +
+ + + + + + diff --git a/src/components/PostList.astro b/src/components/PostList.astro index f171f87..1d2375e 100644 --- a/src/components/PostList.astro +++ b/src/components/PostList.astro @@ -4,6 +4,7 @@ import Folder from "@/assets/icon/folder.png?url"; import Calendar from "@/assets/icon/calendar.png?url"; import type {Post} from "@/types/post"; import {formatDatetime} from "@/lib/format.ts"; +import LazyImage from "@/components/LazyImage.astro"; interface Props { posts: Post[] @@ -23,7 +24,7 @@ posts.map((post) => {
- {post.title} +