"use client"; import * as React from "react"; import { useState, useEffect } from "react"; import { MediumCard } from "../../src/components/MediumCard"; import { BlogCommandBar } from "../../src/components/blog/BlogCommandBar"; import { allPosts as contentPosts } from "contentlayer/generated"; import { SectionHeader } from "../../src/components/SectionHeader"; import { Reveal } from "../../src/components/Reveal"; import { Section } from "../../src/components/Section"; import { AbstractCircuit, GradientMesh } from "../../src/components/Effects"; import { useAnalytics } from "../../src/components/analytics/useAnalytics"; import { motion, AnimatePresence } from "framer-motion"; export default function BlogPage() { const [searchQuery, setSearchQuery] = useState(""); const [activeTags, setActiveTags] = useState([]); const { trackEvent } = useAnalytics(); // Memoize allPosts const allPosts = React.useMemo( () => [...contentPosts].sort( (a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(), ), [], ); const [filteredPosts, setFilteredPosts] = useState(allPosts); // Memoize allTags const allTags = React.useMemo( () => Array.from(new Set(allPosts.flatMap((post) => post.tags || []))), [allPosts], ); const [visibleCount, setVisibleCount] = useState(8); const handleTagToggle = (tag: string) => { setActiveTags((prev) => prev.includes(tag) ? prev.filter((t) => t !== tag) : [...prev, tag], ); setVisibleCount(8); // Reset pagination on filter change }; useEffect(() => { const query = searchQuery.toLowerCase().trim(); let filtered = allPosts; if (query) { filtered = filtered.filter((post) => { const title = post.title.toLowerCase(); const description = post.description.toLowerCase(); const pTagString = (post.tags || []).join(" ").toLowerCase(); return ( title.includes(query) || description.includes(query) || pTagString.includes(query) ); }); } if (activeTags.length > 0) { filtered = filtered.filter((post) => post.tags?.some((tag) => activeTags.includes(tag)), ); } setFilteredPosts(filtered); }, [searchQuery, activeTags, allPosts]); const loadMore = () => { setVisibleCount((prev) => prev + 6); }; const hasMore = visibleCount < filteredPosts.length; const postsToShow = filteredPosts.slice(0, visibleCount); return (
{/* Header Section */}
Knowledge Base

Alle Artikel.

Gedanken über Engineering, Design und die Architektur der Zukunft.

{/* Sticky Filter Bar */}
{/* Posts List (Vertical & Minimal) */}
{postsToShow.length === 0 ? (

Keine Beiträge gefunden.

) : ( {postsToShow.map((post, i) => ( ))} )}
{/* Pagination */} {hasMore && (
)}
); }