4a783d165f
- components/Header.tsx (server, lee sesión): marca, nav (Inicio; login/register o account/logout según sesión), LanguageSwitcher y LogoutButton. - components/LanguageSwitcher.tsx (cliente): cambia de idioma conservando la ruta (next-intl usePathname/useRouter). components/LogoutButton.tsx (compartido). - components/Footer.tsx. app/[locale]/layout.tsx envuelve children con Header/Footer (columna min-h-screen). Se unifica el LogoutButton (se borra el de account/). - messages: namespace Nav. Verificado: home ES/EN con cabecera+nav+idioma+pie; enlaces locale-aware (/en/login); textos por idioma. Al leer sesión en el header, todas las rutas pasan a dinámicas. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import type { Metadata } from 'next'
|
|
import { notFound } from 'next/navigation'
|
|
import { NextIntlClientProvider, hasLocale } from 'next-intl'
|
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
|
import { routing } from '@/i18n/routing'
|
|
import { Header } from '@/components/Header'
|
|
import { Footer } from '@/components/Footer'
|
|
import '../globals.css'
|
|
|
|
export function generateStaticParams() {
|
|
return routing.locales.map((locale) => ({ locale }))
|
|
}
|
|
|
|
// SEO por idioma (SSR) vía Metadata API.
|
|
export async function generateMetadata({
|
|
params,
|
|
}: {
|
|
params: Promise<{ locale: string }>
|
|
}): Promise<Metadata> {
|
|
const { locale } = await params
|
|
const t = await getTranslations({ locale, namespace: 'Metadata' })
|
|
return {
|
|
title: t('title'),
|
|
description: t('description'),
|
|
openGraph: {
|
|
siteName: 'Nova WoW',
|
|
title: t('title'),
|
|
description: t('description'),
|
|
type: 'website',
|
|
locale: locale === 'es' ? 'es_ES' : 'en_US',
|
|
url: 'https://www.nightspire.gg/',
|
|
},
|
|
}
|
|
}
|
|
|
|
export default async function LocaleLayout({
|
|
children,
|
|
params,
|
|
}: {
|
|
children: React.ReactNode
|
|
params: Promise<{ locale: string }>
|
|
}) {
|
|
const { locale } = await params
|
|
if (!hasLocale(routing.locales, locale)) notFound()
|
|
setRequestLocale(locale)
|
|
|
|
return (
|
|
<html lang={locale}>
|
|
<body className="flex min-h-screen flex-col">
|
|
<NextIntlClientProvider>
|
|
<Header />
|
|
<div className="flex-1">{children}</div>
|
|
<Footer />
|
|
</NextIntlClientProvider>
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|