"use client"; import { useState } from "react"; import { Badge, Card, Typography } from "poyraz-ui/atoms"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism"; import { StaggerContainer, StaggerItem } from "@/components/motion-wrapper"; import type { Snippet } from "@/data/snippets"; type SnippetsContentProps = { snippets: Snippet[]; categories: string[]; }; function extractCode(markdown: string) { const match = /```\w*\n([\s\S]*?)```/.exec(markdown); return match ? match[1].trim() : markdown; } export function SnippetsContent({ snippets, categories }: SnippetsContentProps) { const [selected, setSelected] = useState("All"); const filtered = selected === "All" ? snippets : snippets.filter((s) => s.category === selected); return (
Kod Parçacıkları Sıkça kullandığım, tekrar kullanılabilir kod parçacıkları.
{categories.map((cat) => ( ))}
{filtered.map((snippet) => (
{snippet.title} {snippet.description}
{snippet.language}
{extractCode(snippet.markdown)}
))}
{filtered.length === 0 && ( Bu kategoride henüz snippet bulunmuyor. )}
); }