From 66f3ee854390988f618c388b549df16590a2f397 Mon Sep 17 00:00:00 2001 From: L4Ph <4ranci0ne@gmail.com> Date: Wed, 9 Apr 2025 21:17:50 +0900 Subject: [PATCH] refactor: replace 'any' type with CollectionEntry for better type safety in PostCard and PostPage components --- src/components/PostCard.astro | 4 ++-- src/components/PostPage.astro | 35 +++++++++++++++++------------------ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro index 058bb529..a698948d 100644 --- a/src/components/PostCard.astro +++ b/src/components/PostCard.astro @@ -1,5 +1,6 @@ --- import path from "node:path"; +import type { CollectionEntry } from "astro:content"; import { Icon } from "astro-icon/components"; import I18nKey from "../i18n/i18nKey"; import { i18n } from "../i18n/translation"; @@ -9,8 +10,7 @@ import ImageWrapper from "./misc/ImageWrapper.astro"; interface Props { class?: string; - // biome-ignore lint/suspicious/noExplicitAny: - entry: any; + entry: CollectionEntry<"posts">; title: string; url: string; published: Date; diff --git a/src/components/PostPage.astro b/src/components/PostPage.astro index f0ca7a1b..4e46ed46 100644 --- a/src/components/PostPage.astro +++ b/src/components/PostPage.astro @@ -1,4 +1,5 @@ --- +import type { CollectionEntry } from "astro:content"; import { getPostUrlBySlug } from "@utils/url-utils"; import PostCard from "./PostCard.astro"; @@ -8,22 +9,20 @@ let delay = 0; const interval = 50; ---
- {page.data.map((entry: { data: { draft: boolean; title: string; tags: string[]; category: string; published: Date; image: string; description: string; updated: Date; }; slug: string; }) => { - return ( - - ); - })} + {page.data.map((entry: CollectionEntry<"posts">) => ( + + ))}
\ No newline at end of file