From 67b9536cce3759ec7097b22f3fbc07d9df5d160e Mon Sep 17 00:00:00 2001 From: satnaing Date: Sat, 15 Mar 2025 16:37:25 +0700 Subject: [PATCH] refactor: replace `secHeading` with variant prop in Card --- src/components/Card.astro | 8 ++++---- src/pages/index.astro | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/Card.astro b/src/components/Card.astro index 817f706..572eab8 100644 --- a/src/components/Card.astro +++ b/src/components/Card.astro @@ -4,12 +4,12 @@ import type { CollectionEntry } from "astro:content"; import Datetime from "./Datetime.astro"; export interface Props { + variant?: "h2" | "h3"; href?: string; frontmatter: CollectionEntry<"blog">["data"]; - secHeading?: boolean; } -const { href, frontmatter, secHeading = true } = Astro.props; +const { href, frontmatter, variant = "h2" } = Astro.props; const { title, pubDatetime, modDatetime, description } = frontmatter; @@ -25,13 +25,13 @@ const headerProps = { class="inline-block text-lg font-medium text-accent decoration-dashed underline-offset-4 focus-visible:no-underline focus-visible:underline-offset-0" > { - secHeading ? ( + variant === "h2" ? (

{title}

) : (

{title}

) } - +

{description}

diff --git a/src/pages/index.astro b/src/pages/index.astro index 743fb6f..9df2c32 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -77,11 +77,7 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);

Featured

    {featuredPosts.map(({ data, id }) => ( - + ))}
@@ -101,7 +97,7 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured); ) )}