"use client"; import { motion, AnimatePresence } from "framer-motion"; import { useState } from "react"; import Link from "next/link"; import Header from "@/components/Header"; import Footer from "@/components/Footer"; import type { Locale } from "@/i18n-config"; import { blogPosts, BlogPost } from "@/data/blog"; const expo = [0.16, 1, 0.3, 1] as [number, number, number, number]; export default function BlogClient({ lang, dict, initialPosts, }: { lang: Locale; dict: any; initialPosts?: BlogPost[]; }) { const [selectedCategory, setSelectedCategory] = useState(null); const [searchQuery, setSearchQuery] = useState(""); const postsList = initialPosts && initialPosts.length > 0 ? initialPosts : blogPosts; const categories = Array.from( new Set( postsList.map((post) => { const content = post[lang] || post.en; return (content.category as string).split(" · ")[0]; // Main category e.g. YZ, Web3, Web }) ) ); const filteredPosts = postsList.filter((post) => { const content = post[lang] || post.en; const matchesCategory = !selectedCategory || (content.category as string).startsWith(selectedCategory); const matchesSearch = (content.title as string).toLowerCase().includes(searchQuery.toLowerCase()) || (content.excerpt as string).toLowerCase().includes(searchQuery.toLowerCase()) || (content.tags as string[]).some((t: string) => t.toLowerCase().includes(searchQuery.toLowerCase())); return matchesCategory && matchesSearch; }); return (
{/* Header Block */}
{dict.blog.badge}
{dict.blog.title}

{dict.blog.desc}

{/* Filter Controls & Search */}
{/* Categories */}
{categories.map((cat) => ( ))}
{/* Search Box */}
setSearchQuery(e.target.value)} className="w-full font-mono text-[11px] bg-[#EDE8E0] border border-[#C8C2B8] hover:border-[#0A0A0A] focus:border-[#0A0A0A] outline-none px-4 py-3 placeholder-[#A0998E] text-[#0A0A0A] transition-colors" /> {searchQuery && ( )}
{/* Grid List */}
{filteredPosts.map((post, idx) => { const content = post[lang] || post.en; const accent = ["#FFE600", "#FF4500", "#00CC77"][idx % 3] || "#FFE600"; return (
{content.category} {post.date}

{content.title}

{content.excerpt}

{post.author} {post.authorRole}
{/* Category Accent Stripe */}
); })} {filteredPosts.length === 0 && (

{lang === "tr" ? "Sonuç bulunamadı." : "No entries match your parameters."}

)}
); }