import { getTranslations, setRequestLocale } from 'next-intl/server' import { Link } from '@/i18n/navigation' import { ServerClock } from '@/components/ServerClock' import { getNoticias, getServerStatus, type Noticia, type ServerStatus } from '@/lib/home' import { getRealmName } from '@/lib/realm' // SSR por petición: los datos se leen DIRECTAMENTE de MySQL desde el servidor Next. export const dynamic = 'force-dynamic' async function getData(locale: string): Promise<{ noticias: Noticia[]; status: ServerStatus | null }> { const [news, status] = await Promise.allSettled([getNoticias(locale), getServerStatus()]) return { noticias: news.status === 'fulfilled' ? news.value : [], status: status.status === 'fulfilled' ? status.value : null, } } // Sustituye la marca «UltimoWoW»/«Nova WoW» por el nombre del reino SOLO en el // texto visible (fuera de las etiquetas < >), para no romper las URLs de los // enlaces; respeta MAYÚSCULAS y no toca dominios «...com». function brandify(html: string, realm: string): string { const re = /(?:ultimo\s?wow|nova\s?wow)(?!\.com)/gi const repl = (m: string) => (m === m.toUpperCase() ? realm.toUpperCase() : realm) return html.replace(/<[^>]*>|[^<]+/g, (seg) => (seg.startsWith('<') ? seg : seg.replace(re, repl))) } function formatFecha(iso: string | Date | null, locale: string): string { if (!iso) return '' const d = new Date(iso) if (isNaN(d.getTime())) return String(iso) return d.toLocaleDateString(locale === 'en' ? 'en-US' : 'es-ES', { day: 'numeric', month: 'long', year: 'numeric', }) } export default async function HomePage({ params }: { params: Promise<{ locale: string }> }) { const { locale } = await params setRequestLocale(locale) const t = await getTranslations('Misc') const { noticias, status } = await getData(locale) const realmName = await getRealmName() const worldStatus = status ? status.world_status : 'Offline' const worldClass = worldStatus === 'Online' ? 'green-info' : 'red-info' const loginStatus = status ? status.status : 'Offline' const loginClass = loginStatus === 'Online' ? 'green-info' : 'red-info' return (

{realmName} WOTLK 3.4.3

{/* Estado del servidor + reloj en vivo (réplica de la isla React de Django) */}
{realmName}{' '} {status?.expansion ?? ''} {worldStatus}
Login {loginStatus}
{t('home.labelTime')}

{status?.address ?? ''}

{t('home.recruitFriend')}
{t('home.recruitFriend')}

{t('home.introP1', { realm: realmName })}

{t('home.introP2')}


{t('home.introP3')}

{t('home.introP4')}


{t('home.newsHeading')}

{noticias.length === 0 ? (

{t('home.noNews')}

) : ( <> {noticias.map((n) => (

{brandify(n.titulo, realmName)}

{formatFecha(n.fecha, locale)}

{n.enlace && (

{t('home.newsLinkLabel')}{' '} {t('home.here')}

)}


))}

{t('home.showingLatest')}


)}
) }