web-next: noticias usan el nombre del reino en vez de UltimoWoW/NovaWoW

brandify() sustituye «UltimoWoW»/«Nova WoW» por el nombre del reino (realmlist)
en título y contenido de las noticias, SOLO en el texto visible (fuera de las
etiquetas < >) para no romper las URLs de los enlaces (foro.ultimowow.com), y
respetando MAYÚSCULAS (ULTIMOWOW→TRINITY, UltimoWoW→Trinity). No toca dominios.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-13 13:41:48 +00:00
parent 7df9cc408a
commit 8e23f8cc8c
+11 -2
View File
@@ -16,6 +16,15 @@ async function getData(): Promise<{ noticias: Noticia[]; status: ServerStatus |
}
}
// 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): string {
if (!iso) return ''
const d = new Date(iso)
@@ -125,11 +134,11 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
<>
{noticias.map((n) => (
<div key={n.id} className="noticia-item">
<h3>{n.titulo}</h3>
<h3>{brandify(n.titulo, realmName)}</h3>
<span className="date">{formatFecha(n.fecha)}</span>
<p
className="noticia-contenido"
dangerouslySetInnerHTML={{ __html: n.contenido }}
dangerouslySetInnerHTML={{ __html: brandify(n.contenido, realmName) }}
/>
{n.enlace && (
<p>