-
Notifications
You must be signed in to change notification settings - Fork 786
/
page.tsx
39 lines (33 loc) · 1.06 KB
/
page.tsx
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
import ThreadCard from "@/components/cards/ThreadCard";
import { fetchPosts } from "@/lib/actions/thread.actions";
import { currentUser } from "@clerk/nextjs";
export default async function Home() {
const result = await fetchPosts(1,30);
const user = await currentUser();
return (
<>
<h1 className="head-text text-left">Home</h1>
<section className="mt-9 flex flex-col gap-10 ">
{result.posts.length === 0 ? (
<p className="no-result">No Threads Found</p>
) : (
<>
{result.posts.map((post) => (
<ThreadCard
key={post._id}
id={post._id}
currentUserId={user?.id || ""}
parentId={post.parentId}
content={post.text}
author={post.author}
community={post.community}
createdAt={post.createdAt}
comments={post.children}
/>
))}
</>
)}
</section>
</>
)
}