Skip to content

Commit 3674762

Browse files
committed
feat: PostPreview - support card mode
1 parent 9fe4224 commit 3674762

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/components/PostPreview.astro

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import type { CollectionEntry } from 'astro:content'
33
import { getMonthName } from '$/utils'
44
55
interface Props {
6-
post: CollectionEntry<'blog'>
6+
post: CollectionEntry<'blog'>,
7+
asCard?: boolean
78
}
89
9-
const { post: { data: post, slug } } = Astro.props
10+
const { post: { data: post, slug }, asCard = false } = Astro.props
1011
---
11-
<div class="post-preview">
12-
<div class="sm:w-20 md:w-32">
12+
<div class={`post-preview ${asCard && 'post-preview--card'}`}>
13+
<div class="post-preview__date-box">
1314
<div class="post-preview__date">
1415
<span class="post-preview__date__day">{ new Date(post.date).getDate() }</span>
1516
<span class="post-preview__date__month-n-year">{ `${getMonthName(post.date)} ${new Date(post.date).getFullYear()}` }</span>
@@ -26,14 +27,29 @@ const { post: { data: post, slug } } = Astro.props
2627
</div>
2728
<style>
2829
.post-preview {
29-
@apply flex gap-6;
30+
@apply flex gap-6;
31+
}
32+
.post-preview--card {
33+
@apply flex flex-col-reverse gap-4 sm:w-72 md:w-60 lg:w-64;
34+
}
35+
.post-preview__date-box {
36+
@apply sm:w-20 md:w-32
37+
}
38+
.post-preview--card .post-preview__date-box {
39+
@apply w-full
3040
}
3141
.post-preview__date {
3242
@apply flex flex-col w-full text-center;
3343
}
44+
.post-preview--card .post-preview__date {
45+
@apply text-left flex flex-row gap-1
46+
}
3447
.post-preview__date__day {
3548
@apply text-6xl font-semibold text-gray-500 dark:text-gray-300;
3649
}
50+
.post-preview--card .post-preview__date__day {
51+
@apply text-4xl
52+
}
3753
.post-preview__date__month-n-year {
3854
@apply text-gray-400;
3955
}

0 commit comments

Comments
 (0)