summaryrefslogtreecommitdiff
path: root/examples/blog/src/components/PostPreview.astro
blob: 59c54e8fa933608aa83c95160ac7a4be7c5e0ed0 (plain) (blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
export let post;
export let author;

function formatDate(date) {
  return new Date(date).toUTCString().replace(/(\d\d\d\d) .*/, '$1'); // remove everything after YYYY
}
---

<style lang="scss">
.post {
  padding-top: 6rem;
  padding-bottom: 6rem;
  border-bottom: 1px solid rgba(black, 0.25);
  text-align: center;
}

.author {
  text-transform: uppercase;
}

.date {
  font-style: italic;
}

.description {
  font-size: 1.25em;
}

.link {
  text-transform: uppercase;
  font-size: 0.8em;
  margin-left: 1em;
}

h1 {
  font-weight: 700;
  font-size: 2.75em;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-top: 0;
  margin-bottom: 0;
}

time {
  display: block;
  margin-top: 0.25rem;
  margin-bottom: 0.5em;
}
</style>

<article class="post">

  <div class="data">
    <h1>{post.title}</h1>
    <a class="author" href={`/author/${post.author}`}>{author.name}</a>
    <time class="date" datetime={post.date}>{formatDate(post.date)}</time>
    <p class="description">
      {post.description}
      <a class="link" href={post.url}>Read</a>
    </p>
  </div>
</article>