"use client"; import { motion } from "framer-motion"; import { ExternalLink, Calendar, ArrowLeft, Github as GithubIcon, Share2, Code } from "lucide-react"; import Link from "next/link"; import { useEffect, useState } from "react"; import ReactMarkdown from "react-markdown"; import { useTranslations } from "next-intl"; import Image from "next/image"; import { useRouter } from "next/navigation"; export type ProjectDetailData = { id: number; slug: string; title: string; description: string; content: string; tags: string[]; featured: boolean; category: string; date: string; github?: string | null; live?: string | null; button_live_label?: string | null; button_github_label?: string | null; imageUrl?: string | null; technologies?: string[]; }; export default function ProjectDetailClient({ project, locale, }: { project: ProjectDetailData; locale: string; }) { const tCommon = useTranslations("common"); const tDetail = useTranslations("projects.detail"); const router = useRouter(); const [canGoBack, setCanGoBack] = useState(false); useEffect(() => { // Prüfen, ob wir eine History haben (von Home gekommen) if (typeof window !== 'undefined' && window.history.length > 1) { setCanGoBack(true); } try { navigator.sendBeacon?.( "/api/analytics/track", new Blob([JSON.stringify({ type: "pageview", projectId: project.id.toString(), page: `/${locale}/projects/${project.slug}` })], { type: "application/json" }), ); } catch {} }, [project.id, project.slug, locale]); const handleBack = (e: React.MouseEvent) => { e.preventDefault(); // Wenn wir direkt auf die Seite gekommen sind (Deep Link), gehen wir zur Projektliste // Ansonsten nutzen wir den Browser-Back, um an die exakte Stelle der Home oder Liste zurückzukehren if (canGoBack) { router.back(); } else { router.push(`/${locale}/projects`); } }; return (
{project.description}