import { getPosts } from '@/lib/api'
import type { Metadata } from 'next'
import DashboardClient from './DashboardClient'

export const revalidate = 30

const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://trumpsignal.com'

interface OverviewPageProps {
  params: Promise<{ locale: string }>
}

export async function generateMetadata({ params }: OverviewPageProps): Promise<Metadata> {
  const { locale } = await params
  const isZh = false  // i18n shelved — Chinese branches kept as dead code for future revival; see messages/zh.json

  const title = isZh
    ? 'Trump Alpha 信号总览'
    : 'Trump Alpha Signal Monitor'
  const description = isZh
    ? '实时查看 Trump Truth Social 信号、Macro Vibes 宏观氛围、KOL 观点和 talks-vs-trades 分歧，一页掌握核心加密信号。'
    : 'Track Trump Truth Social signals, Macro Vibes (crypto macro regime), KOL calls, and talks-vs-trades divergence in one live crypto dashboard.'
  const path = `${siteUrl}/${locale}`

  return {
    title,
    description,
    alternates: {
      canonical: path,
      languages: {
        en: `${siteUrl}/en`,
        'x-default': `${siteUrl}/en`,
      },
    },
    openGraph: {
      title,
      description,
      url: path,
      locale: isZh ? 'zh_CN' : 'en_US',
      alternateLocale: isZh ? ['en_US'] : ['zh_CN'],
    },
    twitter: {
      title,
      description,
    },
  }
}

export default async function OverviewPage() {
  const posts = await getPosts(500, 1).catch(() => [])

  return (
    <DashboardClient
      initialPosts={posts}
    />
  )
}
