mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 14:52:52 +01:00
refactor: replace 'any' type with CollectionEntry for better type safety in PostCard and PostPage components
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import type { CollectionEntry } from "astro:content";
|
||||||
import { Icon } from "astro-icon/components";
|
import { Icon } from "astro-icon/components";
|
||||||
import I18nKey from "../i18n/i18nKey";
|
import I18nKey from "../i18n/i18nKey";
|
||||||
import { i18n } from "../i18n/translation";
|
import { i18n } from "../i18n/translation";
|
||||||
@@ -9,8 +10,7 @@ import ImageWrapper from "./misc/ImageWrapper.astro";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
class?: string;
|
class?: string;
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
entry: CollectionEntry<"posts">;
|
||||||
entry: any;
|
|
||||||
title: string;
|
title: string;
|
||||||
url: string;
|
url: string;
|
||||||
published: Date;
|
published: Date;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
|
import type { CollectionEntry } from "astro:content";
|
||||||
import { getPostUrlBySlug } from "@utils/url-utils";
|
import { getPostUrlBySlug } from "@utils/url-utils";
|
||||||
import PostCard from "./PostCard.astro";
|
import PostCard from "./PostCard.astro";
|
||||||
|
|
||||||
@@ -8,22 +9,20 @@ let delay = 0;
|
|||||||
const interval = 50;
|
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">
|
<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; }) => {
|
{page.data.map((entry: CollectionEntry<"posts">) => (
|
||||||
return (
|
<PostCard
|
||||||
<PostCard
|
entry={entry}
|
||||||
entry={entry}
|
title={entry.data.title}
|
||||||
title={entry.data.title}
|
tags={entry.data.tags}
|
||||||
tags={entry.data.tags}
|
category={entry.data.category}
|
||||||
category={entry.data.category}
|
published={entry.data.published}
|
||||||
published={entry.data.published}
|
updated={entry.data.updated}
|
||||||
updated={entry.data.updated}
|
url={getPostUrlBySlug(entry.slug)}
|
||||||
url={getPostUrlBySlug(entry.slug)}
|
image={entry.data.image}
|
||||||
image={entry.data.image}
|
description={entry.data.description}
|
||||||
description={entry.data.description}
|
draft={entry.data.draft}
|
||||||
draft={entry.data.draft}
|
class:list="onload-animation"
|
||||||
class:list="onload-animation"
|
style={`animation-delay: calc(var(--content-delay) + ${delay++ * interval}ms);`}
|
||||||
style={`animation-delay: calc(var(--content-delay) + ${delay++ * interval}ms);`}
|
></PostCard>
|
||||||
></PostCard>
|
))}
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user