Files
dalcode-website/components/blog/PostsGridSection.tsx
T
2026-04-29 00:29:14 +08:00

54 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client"
import { useState } from "react"
import { BLOG_POSTS, BLOG_CATEGORIES } from "@/lib/blog-data"
import BlogCard from "@/components/BlogCard"
export default function PostsGridSection() {
const [activeCategory, setActiveCategory] = useState<(typeof BLOG_CATEGORIES)[number]>(BLOG_CATEGORIES[0])
const filtered = activeCategory === BLOG_CATEGORIES[0]
? BLOG_POSTS
: BLOG_POSTS.filter((p) => p.category === activeCategory)
return (
<section className="section">
<div className="w-layout-blockcontainer container-default w-container">
<div data-w-id="41a231e8-d013-bd0a-0639-c179719a51f6" style={{ opacity: "0", filter: "blur(8px)" }} className="title-left-content-right align-center">
<h2></h2>
<div className="category-list-wrapper">
<div role="list" className="category-list">
{BLOG_CATEGORIES.map((cat) => (
<button
key={cat}
className={`category-link${activeCategory === cat ? " w--current" : ""}`}
onClick={() => setActiveCategory(cat)}
type="button"
aria-pressed={activeCategory === cat}
>
{cat}
</button>
))}
</div>
</div>
</div>
<div className="mg-top-regular">
<div data-w-id="e99a5296-8389-ce52-d99c-66f9d94e1815" style={{ opacity: "0", filter: "blur(8px)" }} className="w-dyn-list">
{filtered.length > 0 ? (
<div role="list" className="blog-v1-grid w-dyn-items">
{filtered.map((post) => (
<BlogCard key={post.slug} post={post} variant="grid" />
))}
</div>
) : (
<div className="inner-container _430px">
<p></p>
</div>
)}
</div>
</div>
</div>
</section>
)
}