summaryrefslogtreecommitdiff
path: root/src/lib/components/PostCard.svelte
blob: 7fb9361cf7b3fdf96299e65af6983353efb705d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<script lang="ts">
	import type { Post } from "$lib/utils/posts";

	interface Props {
		post: Post;
	}

	let { post }: Props = $props();

	function formatDate(dateStr: string): string {
		return new Date(dateStr).toLocaleDateString("en-US", {
			year: "numeric",
			month: "long",
			day: "numeric",
		});
	}
</script>

<article>
	<header>
		<a href="/posts/{post.slug}">
			<h1 style="text-decoration: none;">{post.title}</h1>
		</a>
		<small><time datetime={post.date}>{formatDate(post.date)}</time></small>
	</header>
	<p>{post.description}</p>
</article>