"use client"; import { useMemo, useState } from "react"; import Link from "next/link"; import type { BlogPost } from "@/lib/types"; export default function BlogSection({ posts }: { posts: BlogPost[] }) { const allTags = useMemo(() => { const tags = new Set(); posts.forEach((p) => p.tags.forEach((t) => tags.add(t))); return Array.from(tags); }, [posts]); const [activeTag, setActiveTag] = useState("all"); const filtered = useMemo(() => { if (activeTag === "all") return posts; return posts.filter((p) => p.tags.includes(activeTag)); }, [posts, activeTag]); return (
📝 BLOG

游民博客

深度攻略、签证指南与旅居经验分享

{allTags.length > 0 && (
{allTags.map((t) => ( ))}
)}
{filtered.map((post) => (
{post.emoji}
📅 {post.published_at} ⏱️ {post.read_time} 分钟阅读

{post.title}

{post.excerpt}

{post.tags.map((t) => {t})}
阅读全文 → ))}
{filtered.length === 0 && (

该分类暂无文章

)}
); }