-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathindex.tsx
More file actions
31 lines (28 loc) · 850 Bytes
/
Copy pathindex.tsx
File metadata and controls
31 lines (28 loc) · 850 Bytes
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
export const layout = "layout.tsx";
export const title = "Ryan Dahl";
export default function Home({ search }: { search: any }) {
const posts = search.pages("src.path*=/posts/")
.filter((page: any) => page.publish_date)
.sort((a: any, b: any) =>
new Date(b.publish_date).getTime() - new Date(a.publish_date).getTime()
);
return (
<ul class="post-list">
{posts.map((post: any) => {
const formattedDate = new Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "long",
day: "numeric",
}).format(new Date(post.publish_date));
return (
<li key={post.url}>
<h2>
<a href={post.url}>{post.title}</a>
</h2>
<div class="post-date">{formattedDate}</div>
</li>
);
})}
</ul>
);
}