Skip to content

Commit 25e9f4c

Browse files
committed
Create post item and time components
1 parent 35d66c2 commit 25e9f4c

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

src/components/ui/post-item.astro

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
import Time from "@components/ui/time.astro";
3+
4+
type Props = {
5+
title: string;
6+
link: string;
7+
dateCreated: Date;
8+
dateUpdated: Date;
9+
};
10+
const { title, link, dateCreated, dateUpdated } = Astro.props;
11+
---
12+
13+
<li>
14+
<p><a href={link}>{title}</a></p>
15+
<p class="small-text">
16+
Created: <Time date={dateCreated} /> | Updated: <Time date={dateUpdated} />
17+
</p>
18+
</li>
19+
20+
<style lang="scss">
21+
li {
22+
margin-bottom: v-size(5);
23+
}
24+
li:last-child {
25+
margin-bottom: v-size(15);
26+
}
27+
p:last-child {
28+
font-style: italic;
29+
}
30+
31+
@include m-medium {
32+
li:last-child {
33+
margin-bottom: v-size(20);
34+
}
35+
}
36+
</style>

src/components/ui/time.astro

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
type Props = { date: Date; class?: string };
3+
const { date, class: className } = Astro.props;
4+
---
5+
6+
<time class={className} datetime={date.toISOString()}
7+
>{
8+
date.toLocaleDateString("en", {
9+
year: "numeric",
10+
month: "long",
11+
day: "2-digit"
12+
})
13+
}</time
14+
>

0 commit comments

Comments
 (0)