diff --git a/src/app/page.tsx b/src/app/page.tsx index 6baef83b..830f0a94 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,17 +1,99 @@ -export default function Home() { +import { createServerClient, type Storyline } from "../../lib/supabase"; +import { getTrendingStorylines } from "../../lib/ranking"; +import { StoryCard } from "../components/StoryCard"; +import Link from "next/link"; + +export const revalidate = 120; + +export default async function Home() { + const supabase = createServerClient(); + + let recent: Storyline[] = []; + let trending: Storyline[] = []; + + if (supabase) { + const { data } = await supabase + .from("storylines") + .select("*") + .eq("hidden", false) + .eq("sunset", false) + .order("block_timestamp", { ascending: false }) + .limit(8) + .returns(); + + recent = data ?? []; + trending = await getTrendingStorylines(supabase, 4).catch(() => []); + } + + const hasContent = recent.length > 0; + return ( -
-
-

+
+ {/* Compact hero */} +
+

PlotLink

-

+

Collaborative on-chain storytelling. Write the next chapter.

-
- $ npm run dev -
-

+ + + {hasContent ? ( + <> + {/* Trending section */} + {trending.length > 0 && ( +
+
+

+ #trending +

+
+
+ {trending.map((s) => ( + + ))} +
+
+ )} + + {/* Recent feed */} +
+
+

+ #recent +

+ + view all → + +
+
+ {recent.map((s) => ( + + ))} +
+
+ + ) : ( + /* Empty state */ +
+
+ $ no storylines found +
+

+ Be the first to start a story on PlotLink. +

+ + create storyline + +
+ )}
); }