Skip to content

Commit 67b9536

Browse files
committed
refactor: replace secHeading with variant prop in Card
1 parent ad9c26f commit 67b9536

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

src/components/Card.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import type { CollectionEntry } from "astro:content";
44
import Datetime from "./Datetime.astro";
55
66
export interface Props {
7+
variant?: "h2" | "h3";
78
href?: string;
89
frontmatter: CollectionEntry<"blog">["data"];
9-
secHeading?: boolean;
1010
}
1111
12-
const { href, frontmatter, secHeading = true } = Astro.props;
12+
const { href, frontmatter, variant = "h2" } = Astro.props;
1313
1414
const { title, pubDatetime, modDatetime, description } = frontmatter;
1515
@@ -25,13 +25,13 @@ const headerProps = {
2525
class="inline-block text-lg font-medium text-accent decoration-dashed underline-offset-4 focus-visible:no-underline focus-visible:underline-offset-0"
2626
>
2727
{
28-
secHeading ? (
28+
variant === "h2" ? (
2929
<h2 {...headerProps}>{title}</h2>
3030
) : (
3131
<h3 {...headerProps}>{title}</h3>
3232
)
3333
}
3434
</a>
35-
<Datetime pubDatetime={pubDatetime} modDatetime={modDatetime} />
35+
<Datetime {pubDatetime} {modDatetime} />
3636
<p>{description}</p>
3737
</li>

src/pages/index.astro

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,7 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
7777
<h2 class="text-2xl font-semibold tracking-wide">Featured</h2>
7878
<ul>
7979
{featuredPosts.map(({ data, id }) => (
80-
<Card
81-
href={`/posts/${id}/`}
82-
frontmatter={data}
83-
secHeading={false}
84-
/>
80+
<Card href={`/posts/${id}/`} frontmatter={data} variant="h3" />
8581
))}
8682
</ul>
8783
</section>
@@ -101,7 +97,7 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
10197
<Card
10298
href={`/posts/${id}/`}
10399
frontmatter={data}
104-
secHeading={false}
100+
variant="h3"
105101
/>
106102
)
107103
)}

0 commit comments

Comments
 (0)