summary refs log tree commit diff
path: root/app/posts/page.tsx
blob: e713259038b51707312fd55892f7cca05c47196d (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
import InfoBar from "~/components/InfoBar"
import { Post, getPostSlugs, loadSinglePage } from "~/utils/post"

export default async function Posts() {
  const slugs = await getPostSlugs()
  const posts = await Promise.all(slugs.map(loadSinglePage))

  const sortedPosts = posts.sort((a: Post, b: Post) => b.date.valueOf() - a.date.valueOf())

  return (
    <>
      <h1 className="pageTitle">
        Posts
      </h1>
      <main>
        {sortedPosts.map((post: Post) => (
          <div className="mainColumn">
            <InfoBar authorName={post.author} publishedDate={post.date} />
            <h2>{post.title}</h2>
            <p>{post.subtitle}</p>
            <a href={`/posts/${post.slug}`}>Read Post =&gt;</a>
          </div>
        ))}
      </main>
    </>
  )
}