import Image from "next/image"; import Link from "next/link"; import { ArrowRight, MessageCircle, Phone, Tag } from "lucide-react"; import { getSiteSettings, listPublishedPosts, listServices, } from "@/lib/data"; import { siteConfig } from "@/lib/site-config"; interface Props { /** * Hangi yazıyı/sayfayı görüntülüyoruz — listede gizlemek için. */ currentSlug?: string; } export async function ContentSidebar({ currentSlug }: Props) { const [settings, services, posts] = await Promise.all([ getSiteSettings(), listServices(), listPublishedPosts({ limit: 5 }), ]); const phoneRaw = settings?.contact_phone_raw ?? siteConfig.contact.phoneRaw; const phone = settings?.contact_phone ?? siteConfig.contact.phone; const waCleaned = phoneRaw.replace(/[^\d]/g, ""); const waMessage = settings?.whatsapp_message ?? ""; const waHref = `https://wa.me/${waCleaned}${ waMessage ? `?text=${encodeURIComponent(waMessage)}` : "" }`; const otherPosts = posts.filter((p) => p.slug !== currentSlug).slice(0, 4); // Etiket sayımı (tüm yazılardan toplu) const tagCount = new Map(); posts.forEach((p) => (p.tags ?? []).forEach((t) => tagCount.set(t, (tagCount.get(t) ?? 0) + 1), ), ); const topTags = Array.from(tagCount.entries()) .sort((a, b) => b[1] - a[1]) .slice(0, 10); return ( ); }