import type { Metadata } from 'next'
import { ExpertsPageClient } from './ExpertsPageClient'
import { getExperts } from '@/lib/server-experts'
import { getSiteHome } from '@/lib/server-site'

export const metadata: Metadata = { title: '专家平台' }

export default async function ExpertsPage() {
  const [experts, siteHome] = await Promise.all([getExperts(), getSiteHome()])
  const heroSlides = siteHome.assets
    .filter((asset) => asset.key.startsWith('expert_platform_hero_') && asset.imageUrl)
    .sort((a, b) => a.sortOrder - b.sortOrder)
    .slice(0, 3)
    .map((asset) => ({ imageUrl: asset.imageUrl, label: asset.label || asset.title || '专家平台主视觉' }))

  return <ExpertsPageClient initialExperts={experts} heroSlides={heroSlides} />
}
