'use client'; import * as React from 'react'; import { useState, useEffect } from 'react'; import { MediumCard } from '../../src/components/MediumCard'; import { SearchBar } from '../../src/components/SearchBar'; import { Tag } from '../../src/components/Tag'; import { blogPosts } from '../../src/data/blogPosts'; import { PageHeader } from '../../src/components/PageHeader'; import { Reveal } from '../../src/components/Reveal'; export default function BlogPage() { const [searchQuery, setSearchQuery] = useState(''); const [filteredPosts, setFilteredPosts] = useState(blogPosts); // Sort posts by date const allPosts = [...blogPosts].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime() ); // Get unique tags const allTags = Array.from(new Set(allPosts.flatMap(post => post.tags || []))); useEffect(() => { const query = searchQuery.toLowerCase().trim(); if (query.startsWith('#')) { const tag = query.slice(1); setFilteredPosts(allPosts.filter(post => post.tags?.some(t => t.toLowerCase() === tag.toLowerCase()) )); } else { setFilteredPosts(allPosts.filter(post => { const title = post.title.toLowerCase(); const description = post.description.toLowerCase(); const tags = (post.tags || []).join(' ').toLowerCase(); return title.includes(query) || description.includes(query) || tags.includes(query); })); } }, [searchQuery]); const filterByTag = (tag: string) => { setSearchQuery(`#${tag}`); }; return (
Blog
& Notes.} description="A public notebook of things I figured out, mistakes I made, and tools I tested." backgroundSymbol="B" />
{/* Sidebar / Filter area */}

Suchen

{allTags.length > 0 && (

Themen

{allTags.map((tag, index) => ( ))}
)}
{/* Posts area */}
{filteredPosts.length === 0 ? (

No posts found matching your criteria.

) : ( filteredPosts.map((post, i) => ( )) )}
); }