refactor: replace 'any' type with CollectionEntry for better type safety in PostCard and PostPage components

This commit is contained in:
L4Ph
2025-04-09 21:17:50 +09:00
parent ad33c58dc7
commit 66f3ee8543
2 changed files with 19 additions and 20 deletions

View File

@@ -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: <explanation>
entry: any;
entry: CollectionEntry<"posts">;
title: string;
url: string;
published: Date;

View File

@@ -1,4 +1,5 @@
---
import type { CollectionEntry } from "astro:content";
import { getPostUrlBySlug } from "@utils/url-utils";
import PostCard from "./PostCard.astro";
@@ -8,8 +9,7 @@ let delay = 0;
const interval = 50;
---
<div class="transition flex flex-col rounded-[var(--radius-large)] bg-[var(--card-bg)] py-1 md:py-0 md:bg-transparent md:gap-4 mb-4">
{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">) => (
<PostCard
entry={entry}
title={entry.data.title}
@@ -24,6 +24,5 @@ const interval = 50;
class:list="onload-animation"
style={`animation-delay: calc(var(--content-delay) + ${delay++ * interval}ms);`}
></PostCard>
);
})}
))}
</div>