import Image from "next/image"; import Link from "next/link"; import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { ArrowLeft, Building2, Calendar, Clock, ExternalLink, Tag } from "lucide-react"; import { renderContent } from "@/lib/content-render"; import { getProjectBySlug, listProjects } from "@/lib/data"; import { buildMetadata } from "@/lib/seo"; import { Gallery } from "@/components/gallery"; import { TrendingUp } from "lucide-react"; import type { ProjectMetric } from "@/lib/types"; function parseMetrics(items?: string[] | null): ProjectMetric[] { if (!items) return []; const out: ProjectMetric[] = []; for (const raw of items) { try { const obj = JSON.parse(raw) as Partial; if (obj.value && obj.label) out.push({ value: obj.value, label: obj.label }); } catch { const [value, label] = raw.split("|").map((s) => s.trim()); if (value && label) out.push({ value, label }); } } return out; } export async function generateMetadata({ params, }: { params: Promise<{ slug: string }>; }): Promise { const { slug } = await params; const project = await getProjectBySlug(slug); if (!project) return { title: "Proje bulunamadı" }; return buildMetadata(`/projeler/${slug}`, { title: project.title, description: project.description.slice(0, 160), openGraph: { title: project.title, description: project.description.slice(0, 160), images: project.image_url ? [{ url: project.image_url }] : undefined, type: "article", }, }); } export default async function ProjectDetailPage({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const project = await getProjectBySlug(slug); if (!project) notFound(); const html = renderContent(project.content); const metrics = parseMetrics(project.metrics); const meta: { icon: React.ReactNode; label: string; value: string }[] = []; if (project.client_name) meta.push({ icon: , label: "Müşteri", value: project.client_name }); if (project.industry) meta.push({ icon: , label: "Sektör", value: project.industry }); if (project.duration) meta.push({ icon: , label: "Süre", value: project.duration }); if (project.year) meta.push({ icon: , label: "Yıl", value: String(project.year) }); const relatedProjects = ( await listProjects({ limit: 4 }) ).filter((p) => p.$id !== project.$id).slice(0, 3); return ( <>
Tüm projeler
{project.category && ( {project.category} )}

{project.title}

{project.description}

{project.live_url && ( Projeyi canlı görüntüle )} {project.technologies && project.technologies.length > 0 && (

Teknolojiler

{project.technologies.map((t) => ( {t} ))}
)}
{meta.length > 0 && (
{meta.map((m) => (
{m.icon} {m.label}
{m.value}
))}
)}
{project.image_url && (
{project.title}
)} {metrics.length > 0 && (

Sonuçlar

{metrics.map((m, i) => (

{m.value}

{m.label}

))}
)}
{html && (
)} {project.gallery && project.gallery.length > 0 && (

Galeri

Görsellerin üzerine tıklayarak büyütebilirsiniz.

)}
{relatedProjects.length > 0 && (

Diğer projeler

{relatedProjects.map((p) => (
{p.image_url ? ( {p.title} ) : (
{p.title.charAt(0)}
)}

{p.title}

{p.category}

))}
)} ); }