|
1 | 1 | "use client"; |
2 | 2 |
|
3 | | -import { ArrowRight } from "lucide-react"; |
4 | 3 | import { motion } from "framer-motion"; |
| 4 | +import { useEffect, useState } from "react"; |
| 5 | + |
| 6 | +type BlogPost = { |
| 7 | + id: string; |
| 8 | + title: string; |
| 9 | + content: string | null; |
| 10 | +}; |
5 | 11 |
|
6 | 12 | export default function Home() { |
| 13 | + const [posts, setPosts] = useState<BlogPost[]>([]); |
| 14 | + |
| 15 | + useEffect(() => { |
| 16 | + let isMounted = true; |
| 17 | + |
| 18 | + async function loadPosts() { |
| 19 | + const res = await fetch("/api/blogs", { cache: "no-store" }); |
| 20 | + if (!res.ok || !isMounted) return; |
| 21 | + |
| 22 | + const data = (await res.json()) as BlogPost[]; |
| 23 | + setPosts(data); |
| 24 | + } |
| 25 | + |
| 26 | + loadPosts(); |
| 27 | + |
| 28 | + return () => { |
| 29 | + isMounted = false; |
| 30 | + }; |
| 31 | + }, []); |
| 32 | + |
7 | 33 | return ( |
8 | 34 | <div className="relative isolate flex min-h-screen items-center justify-center overflow-hidden"> |
9 | 35 | <div className="pointer-events-none absolute inset-0 overflow-hidden bg-white dark:bg-gray-950"> |
@@ -35,10 +61,56 @@ export default function Home() { |
35 | 61 | initial={{ opacity: 0, y: 24, filter: "blur(6px)" }} |
36 | 62 | animate={{ opacity: 1, y: 0, filter: "blur(0px)" }} |
37 | 63 | transition={{ duration: 0.8, ease: [0.22, 1, 0.36, 1] }} |
38 | | - className="font-mono text-5xl tracking-tight text-gray-900 select-none sm:text-7xl md:text-8xl lg:text-9xl dark:text-white"> |
| 64 | + className="font-mono text-4xl tracking-tight text-gray-900 select-none sm:text-6xl md:text-7xl lg:text-8xl dark:text-white"> |
39 | 65 |
|
40 | | - sander.tf |
| 66 | + blogs |
41 | 67 | </motion.h1> |
| 68 | + |
| 69 | + <motion.p |
| 70 | + initial={{ opacity: 0, y: 16 }} |
| 71 | + animate={{ opacity: 1, y: 0 }} |
| 72 | + transition={{ delay: 0.15, duration: 0.6 }} |
| 73 | + className="mt-4 max-w-2xl text-sm text-slate-600 dark:text-slate-300 sm:text-base" |
| 74 | + > |
| 75 | + Thoughts, expiriments and logs. |
| 76 | + </motion.p> |
| 77 | + |
| 78 | + {posts.length === 0 ? ( |
| 79 | + <motion.div |
| 80 | + initial={{ opacity: 0, y: 12 }} |
| 81 | + animate={{ opacity: 1, y: 0 }} |
| 82 | + transition={{ delay: 0.25, duration: 0.5 }} |
| 83 | + className="mt-10 rounded-2xl border border-slate-200/700 bg-white/70 p-6 text-slate-700 shadow-sm backdrop-blur dark:border-slate-700/70 dark:bg-slate-900/40 dark:text-slate-200" |
| 84 | + > |
| 85 | + No blogs posted. |
| 86 | + </motion.div> |
| 87 | + ) : ( |
| 88 | + <div className="mt-10 grid grid-cols-1 gap-4 sm:gap-5"> |
| 89 | + {posts.map((p, i) => ( |
| 90 | + <motion.article |
| 91 | + key={p.id} |
| 92 | + initial={{ opacity: 0, y: 18 }} |
| 93 | + animate={{ opacity: 1, y: 0 }} |
| 94 | + transition={{ delay: 0.08 * i, duration: 0.5 }} |
| 95 | + className="group rounded-2xl border border-slate-200/70 bg-white/70 p-5 shadow-sm backdrop-blur transition hover:-translate-y-0.5 hover:shadow-md dark:border-slate-700/70 dark:bg-slate-900/40" |
| 96 | + > |
| 97 | + <h2 className="text-xl font-semibold tracking-tight text-slate-900 dark:text-white"> |
| 98 | + {p.title} |
| 99 | + </h2> |
| 100 | + |
| 101 | + <p className="mt-2 line-clamp-3 text-sm leading-6 text-slate-600 dark:text-slate-300"> |
| 102 | + {p.content ?? "Geen inhoud toegevoegd."} |
| 103 | + </p> |
| 104 | + |
| 105 | + <div className="mt-4"> |
| 106 | + <button className="inline-flex items-center rounded-full border border-slate-300 px-3 py-1.5 text-xs font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-600 dark:text-slate-200 dark:hover:bg-slate-800"> |
| 107 | + Read more |
| 108 | + </button> |
| 109 | + </div> |
| 110 | + </motion.article> |
| 111 | + ))} |
| 112 | + </div> |
| 113 | + )} |
42 | 114 | </div> |
43 | 115 | </div> |
44 | 116 | ); |
|
0 commit comments