"use client";
import { useEffect, useState } from "react";
import { motion } from "framer-motion";
import { Sparkles } from "lucide-react";
import WebStuff from "@/components/Web";
import { useParams } from "next/navigation";
import { PostPreview } from "@/lib/posts";
export default function BlogPost() {
const [post, setPost] = useState<(PostPreview & { content: string }) | null>(
null
);
const [mounted, setMounted] = useState(false);
const { slug } = useParams();
useEffect(() => {
setMounted(true);
}, []);
useEffect(() => {
async function fetchPost() {
const res = await fetch(`/api/blog/${slug}`);
const data = await res.json();
setPost(data);
}
fetchPost();
}, [slug]);
if (!post) {
return (
Loading post...
);
}
const containerVariants = {
hidden: { opacity: 0 },
visible: { opacity: 1, transition: { staggerChildren: 0.1 } },
};
const itemVariants = {
hidden: { y: 20, opacity: 0 },
visible: { y: 0, opacity: 1, transition: { duration: 0.5 } },
};
return (
Hero Section
{post.category}
{post.title}
{post.author}
•
{new Date(post.date).toLocaleDateString()}
{post.readingTime && (
<>
•
{post.readingTime} min read
>
)}
{post.tags?.map((tag, idx) => (
{tag}
))}
{/* Optional Featured Image */}
{post.image && (
)}
{/* Post Content */}
);
}