summaryrefslogtreecommitdiff
path: root/src/components/BlogCard.astro
blob: 7ab42d7d3aad06359eb1633b8345f26911698fe2 (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
28
29
30
31
32
33
34
35
36
37
38
---
import type { CollectionEntry } from "astro:content";

interface Props extends CollectionEntry<"blog"> {}

const { id, data } = Astro.props;
const { title, description, dateCreated, lang } = data;

const href = `/blog/read/${id}`;
---

<article>
  <h2>
    <a {href}>{title}</a>
  </h2>
  <p>{description}</p>
  <footer>
    <span><time datetime={(dateCreated as Date).toISOString()}>{
        new Intl.DateTimeFormat(lang, {
          weekday: "long",
          year: "numeric",
          month: "long",
          day: "numeric",
          hour: "2-digit",
          minute: "2-digit",
          timeZoneName: "long",
        }).format(dateCreated)
      }</time></span>
  </footer>
</article>

<style>
  article {
    border-block-end: 1px solid #181818;
    padding-block-end: 1rem;
    margin-block: 0.5rem;
  }
</style>