import Link from 'next/link'; import { ChevronRight } from 'lucide-react'; import type { Metadata } from 'next'; const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001'; async function getWikiTerm(key: string) { try { const res = await fetch(`${API_URL}/api/wiki/${encodeURIComponent(key)}`, { next: { revalidate: 60 } }); if (!res.ok) throw new Error('Failed to fetch wiki term'); return res.json(); } catch (error) { console.error(error); return null; } } export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise { const { slug } = await params; const term = await getWikiTerm(slug); if (!term) return { title: 'ترکیب علمی یافت نشد' }; return { title: term.metaTitle || term.term, description: term.metaDescription || term.definition?.substring(0, 160), }; } export default async function WikiTermPage({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const term = await getWikiTerm(slug); if (!term) { return (

ترکیب علمی یافت نشد

بازگشت به دانشنامه
); } return (
بازگشت به دانشنامه

{term.term}

); }