store: la ruta pasa a ser /store-<reino> y /store da 404
Como el original (/store-bennu). El slug sale de acore_auth.realmlist, así que no puede ser una carpeta fija: lo resuelve la ruta dinámica `[realm]`, que ya servía /<slug>-realm y /<slug>-players con este mismo patrón. Solo hubo que añadirle el tipo `store`; el contenido de la página se mueve a components/StorePage.tsx. /store da 404 sin código extra: al no existir ya la carpeta estática `store`, entra por `[realm]`, no resuelve y cae en el notFound() que ya estaba. Enlaces actualizados: el de /my-account (AccountTools, que es cliente y recibe el href ya calculado) y el cancelUrl de la pasarela, que devolvía a /store. Verificado: /es/store-trinity y /en/store-trinity dan 200 y la tienda carga el catálogo; /es/store y /en/store dan 404; un slug ajeno (/es/store-bennu) también 404; /es/trinity-realm y /es/trinity-players siguen bien; y el enlace de /my-account apunta a /es/store-trinity. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,31 +3,40 @@ import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { getRealmName, realmSlug } from '@/lib/realm'
|
||||
import { RealmInfo } from '@/components/RealmInfo'
|
||||
import { StorePage } from '@/components/StorePage'
|
||||
import { PlayersBoard } from '@/components/PlayersBoard'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
type Kind = 'realm' | 'players'
|
||||
type Kind = 'realm' | 'players' | 'store'
|
||||
|
||||
// Rutas dinámicas del reino (el slug viene de acore_auth.realmlist):
|
||||
// /<slug>-realm → información del reino (Rates/Horarios)
|
||||
// /<slug>-players → estadísticas de personajes (datos reales de la BD)
|
||||
// /store-<slug> → la tienda (así la nombra el original: /store-bennu)
|
||||
// Cualquier otro valor cae en notFound(), y por eso /store a secas da 404: al no
|
||||
// existir ya una ruta estática `store`, entra por aquí y no resuelve.
|
||||
async function resolve(param: string): Promise<{ name: string; kind: Kind } | null> {
|
||||
const name = await getRealmName()
|
||||
const slug = realmSlug(name)
|
||||
if (param === `${slug}-realm`) return { name, kind: 'realm' }
|
||||
if (param === `${slug}-players`) return { name, kind: 'players' }
|
||||
if (param === `store-${slug}`) return { name, kind: 'store' }
|
||||
return null
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ realm: string }>
|
||||
params: Promise<{ locale: string; realm: string }>
|
||||
}): Promise<Metadata> {
|
||||
const { realm } = await params
|
||||
const r = await resolve(realm)
|
||||
if (!r) return {}
|
||||
if (r.kind === 'store') {
|
||||
const t = await getTranslations({ locale: (await params).locale, namespace: 'Store' })
|
||||
return { title: `${t('title')} - ${r.name}` }
|
||||
}
|
||||
return { title: `${r.kind === 'players' ? 'Personajes' : 'Reino'} - ${r.name}` }
|
||||
}
|
||||
|
||||
@@ -38,9 +47,12 @@ export default async function RealmPage({
|
||||
}) {
|
||||
const { locale, realm } = await params
|
||||
setRequestLocale(locale)
|
||||
const t = await getTranslations('Misc')
|
||||
const r = await resolve(realm)
|
||||
if (!r) notFound()
|
||||
// La tienda trae su propia cabecera y sus comprobaciones de sesión.
|
||||
if (r.kind === 'store') return <StorePage locale={locale} realm={r.name} />
|
||||
|
||||
const t = await getTranslations('Misc')
|
||||
|
||||
const heading = r.kind === 'players' ? t('realm.charactersHeading') : t('realm.realmHeading')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user