| 1 | --- |
| 2 | import type { CollectionEntry } from "astro:content"; |
| 3 | import type { IElement } from "@/data/shared"; |
| 4 | import { getFormattedDate } from "@/utils"; |
| 5 | |
| 6 | interface Props extends IElement { |
| 7 | post: CollectionEntry<"post">; |
| 8 | withDesc?: boolean; |
| 9 | } |
| 10 | |
| 11 | const { post, as: Element = "div", withDesc = false } = Astro.props; |
| 12 | const date = new Date(post.data.publishDate); |
| 13 | const datetime = date.toISOString(); |
| 14 | const postDate = getFormattedDate(date, { month: "short" }); |
| 15 | --- |
| 16 | |
| 17 | <time datetime={datetime} class="min-w-[120px] text-gray-500">{postDate}</time> |
| 18 | <Element> |
| 19 | <a href={`/posts/${post.slug}`} class="cactus-link" rel="prefetch"> |
| 20 | {post.data.title} |
| 21 | </a> |
| 22 | </Element> |
| 23 | {withDesc && <q class="mt-2 block italic line-clamp-3">{post.data.description}</q>} |