Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8e9fd0c4c | ||
|
|
83e6d9305d | ||
|
|
f7135c4fb9 | ||
|
|
acd9265ecc |
@@ -10,6 +10,7 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"dompurify": "^3.4.14",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
|
||||
+56
@@ -173,6 +173,62 @@ img {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
/* Cita destacada (parrafo en cursiva con borde horizontal en el original:
|
||||
ver is_pull_quote() en scripts/extract_site.py) */
|
||||
.section-quote {
|
||||
font-family: var(--font-body);
|
||||
font-style: italic;
|
||||
font-size: 1.3rem;
|
||||
line-height: 1.3;
|
||||
margin: 1.75rem 0;
|
||||
padding: 1.1rem 1.25rem;
|
||||
border-top: 2px solid #e2e2e2;
|
||||
border-bottom: 2px solid #e2e2e2;
|
||||
}
|
||||
.section--hero .section-quote {
|
||||
border-color: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
/* Foto de fondo a pantalla completa de un contenedor Elementor (ver
|
||||
background_image en scripts/extract_site.py). Se sale del ancho maximo
|
||||
de .section-inner para ser full-bleed de verdad. */
|
||||
.section-banner {
|
||||
width: 100vw;
|
||||
margin-inline: calc(50% - 50vw);
|
||||
margin-block: 2.5rem;
|
||||
min-height: 55vh;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
/* Rejilla de tarjetas (p.ej. "Algunos mitos sobre la inmigracion...": ver
|
||||
is_card_row() en scripts/extract_site.py) */
|
||||
.section-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||
gap: 1.25rem;
|
||||
margin: 1.75rem 0;
|
||||
}
|
||||
.section-grid-card {
|
||||
border: 1px solid #e4e4e4;
|
||||
border-radius: 12px;
|
||||
padding: 1.75rem 1rem 1.25rem;
|
||||
box-shadow: 0 2px 10px rgba(15, 23, 43, 0.06);
|
||||
transition: box-shadow 0.2s ease;
|
||||
}
|
||||
.section-grid-card:hover {
|
||||
box-shadow: 0 4px 18px rgba(15, 23, 43, 0.14);
|
||||
}
|
||||
.section-grid-card .section-heading {
|
||||
font-size: 1.15rem;
|
||||
margin-bottom: 0.6rem;
|
||||
}
|
||||
.section-grid-card .section-paragraph {
|
||||
font-size: 0.95rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* ------- Footer ------- */
|
||||
.site-footer {
|
||||
background: var(--color-bg-dark);
|
||||
|
||||
+11
-38
@@ -1,52 +1,25 @@
|
||||
import Navbar from './components/Navbar'
|
||||
import Section from './components/Section'
|
||||
import Footer from './components/Footer'
|
||||
import siteData from './content/site.json'
|
||||
import Home from './pages/Home'
|
||||
import LegalPage from './pages/LegalPage'
|
||||
import NotFound from './pages/NotFound'
|
||||
import { useRouter } from './router/router'
|
||||
import './App.css'
|
||||
|
||||
// Variantes visuales por anchor para romper la monotonía
|
||||
const VARIANTS = {
|
||||
'first-section': 'hero',
|
||||
significa: 'default',
|
||||
'inmigración_masiva': 'alt',
|
||||
detener_el_reemplazo_poblacional: 'default',
|
||||
que_podemoshacer: 'alt',
|
||||
precedentes_historicos: 'default',
|
||||
contacto: 'hero',
|
||||
const ROUTES = {
|
||||
'/': () => <Home />,
|
||||
'/informacion-sobre-las-cookies': () => <LegalPage pageKey="cookies" />,
|
||||
'/aviso-legal-y-proteccion-de-datos': () => <LegalPage pageKey="avisoLegal" />,
|
||||
}
|
||||
|
||||
// Orden en que aparecen en la página — coincide con el orden del menú
|
||||
const SECTION_ORDER = [
|
||||
'first-section',
|
||||
'significa',
|
||||
'inmigración_masiva',
|
||||
'detener_el_reemplazo_poblacional',
|
||||
'que_podemoshacer',
|
||||
'precedentes_historicos',
|
||||
'contacto',
|
||||
]
|
||||
|
||||
function App() {
|
||||
const byAnchor = Object.fromEntries(
|
||||
siteData.sections.map((s) => [s.anchor, s])
|
||||
)
|
||||
const { pathname } = useRouter()
|
||||
const renderPage = ROUTES[pathname]
|
||||
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
<main>
|
||||
{SECTION_ORDER.map((anchor) => {
|
||||
const s = byAnchor[anchor]
|
||||
if (!s) return null
|
||||
return (
|
||||
<Section
|
||||
key={anchor}
|
||||
section={s}
|
||||
variant={VARIANTS[anchor] || 'default'}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</main>
|
||||
<main>{renderPage ? renderPage() : <NotFound />}</main>
|
||||
<Footer />
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Link } from '../router/router'
|
||||
import siteData from '../content/site.json'
|
||||
|
||||
export default function Footer() {
|
||||
const { site } = siteData
|
||||
const { site, menus } = siteData
|
||||
const footerLinks = menus?.footer || []
|
||||
|
||||
return (
|
||||
<footer className="site-footer" id="contacto-footer">
|
||||
<div className="site-footer-inner">
|
||||
@@ -10,12 +13,11 @@ export default function Footer() {
|
||||
{site.description} — Todos los derechos reservados
|
||||
</p>
|
||||
<ul className="site-footer-links">
|
||||
<li>
|
||||
<a href="/informacion-sobre-las-cookies">Cookies</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/aviso-legal-y-proteccion-de-datos">Aviso legal</a>
|
||||
</li>
|
||||
{footerLinks.map((item) => (
|
||||
<li key={item.order}>
|
||||
<Link to={item.url}>{item.title}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
import { Link, useRouter } from '../router/router'
|
||||
import siteData from '../content/site.json'
|
||||
|
||||
export default function Navbar() {
|
||||
const { site, menu } = siteData
|
||||
const { site, menus } = siteData
|
||||
const { pathname } = useRouter()
|
||||
const items = menus?.principal || []
|
||||
|
||||
return (
|
||||
<nav className="nav">
|
||||
<div className="nav-inner">
|
||||
<a href="#first-section" className="brand">
|
||||
<Link to="/" className="brand">
|
||||
{site.name}
|
||||
</a>
|
||||
</Link>
|
||||
<ul className="nav-links">
|
||||
{menu.map((item) => (
|
||||
<li key={item.order}>
|
||||
<a href={item.url}>{item.title}</a>
|
||||
</li>
|
||||
))}
|
||||
{items.map((item) => {
|
||||
// los items del menu principal son anclas de la home (#seccion);
|
||||
// desde otra pagina hay que volver primero a "/"
|
||||
const to = item.url.startsWith('#') && pathname !== '/'
|
||||
? `/${item.url}`
|
||||
: item.url
|
||||
return (
|
||||
<li key={item.order}>
|
||||
<Link to={to}>{item.title}</Link>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -13,7 +13,7 @@ export default function Section({ section, variant = 'default' }) {
|
||||
return (
|
||||
<section id={anchor} className={`section section--${variant}`}>
|
||||
<div className="section-inner">
|
||||
<Content {...section} truncate />
|
||||
<Content blocks={section.blocks} />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import Content from './Content'
|
||||
import { sanitizeHtml } from '../../lib/sanitize'
|
||||
|
||||
export default function Accordion({ items = [] }) {
|
||||
const [openIndex, setOpenIndex] = useState(null)
|
||||
@@ -17,14 +18,14 @@ export default function Accordion({ items = [] }) {
|
||||
aria-expanded={isOpen}
|
||||
onClick={() => setOpenIndex(isOpen ? null : i)}
|
||||
>
|
||||
<span dangerouslySetInnerHTML={{ __html: item.title }} />
|
||||
<span dangerouslySetInnerHTML={{ __html: sanitizeHtml(item.title) }} />
|
||||
<span className="pa-accordion-icon" aria-hidden="true">
|
||||
{isOpen ? '−' : '+'}
|
||||
</span>
|
||||
</button>
|
||||
{isOpen && (
|
||||
<div className="pa-accordion-panel">
|
||||
<Content {...item} />
|
||||
<Content blocks={item.blocks} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function Carousel({ slides = [] }) {
|
||||
<div className="pa-carousel-track" ref={trackRef}>
|
||||
{slides.map((slide, i) => (
|
||||
<div key={i} className="pa-carousel-slide">
|
||||
<Content {...slide} />
|
||||
<Content blocks={slide.blocks} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import './content.css'
|
||||
import { sanitizeHtml } from '../../lib/sanitize'
|
||||
import Accordion from './Accordion'
|
||||
import Tabs from './Tabs'
|
||||
import Carousel from './Carousel'
|
||||
@@ -7,95 +8,118 @@ import ProgressBar from './ProgressBar'
|
||||
import FancyText from './FancyText'
|
||||
|
||||
/**
|
||||
* Renderiza un bloque de contenido extraido de Elementor: encabezados,
|
||||
* parrafos, imagenes, listas y widgets especiales (acordeon, tabs,
|
||||
* carrusel, slideshow, barra de progreso, texto animado).
|
||||
* Renderiza una lista ORDENADA de bloques extraidos de Elementor (ver
|
||||
* extract_container() en scripts/extract_site.py): encabezados, parrafos,
|
||||
* citas destacadas, imagenes, listas, rejillas de tarjetas, fotos de fondo
|
||||
* a pantalla completa, y los widgets especiales de siempre (acordeon,
|
||||
* tabs, carrusel, slideshow, barra de progreso, texto animado).
|
||||
*
|
||||
* A diferencia de la version anterior (5 arrays planos por tipo), aqui el
|
||||
* orden del array "blocks" ES el orden real del documento original, y cada
|
||||
* bloque trae su propio papel visual -- por eso una rejilla de tarjetas o
|
||||
* una cita destacada ya no se confunden con un parrafo mas.
|
||||
*
|
||||
* Se usa tanto para una seccion completa de la home/paginas legales como,
|
||||
* recursivamente, para el contenido anidado dentro de un panel de
|
||||
* acordeon/tab/slide de carrusel (por eso "truncate" es false por defecto:
|
||||
* los paneles anidados suelen ser pequenos y no conviene recortarlos).
|
||||
* recursivamente, para el contenido anidado dentro de una tarjeta de
|
||||
* rejilla o un panel de acordeon/tab/slide de carrusel.
|
||||
*/
|
||||
export default function Content({
|
||||
headings = [],
|
||||
paragraphs = [],
|
||||
images = [],
|
||||
lists = [],
|
||||
widgets = [],
|
||||
truncate = false,
|
||||
}) {
|
||||
const shownHeadings = truncate ? headings.slice(0, 2) : headings
|
||||
const shownParagraphs = truncate ? paragraphs.slice(0, 5) : paragraphs
|
||||
const shownImages = truncate ? images.slice(0, 1) : images
|
||||
|
||||
export default function Content({ blocks = [] }) {
|
||||
return (
|
||||
<>
|
||||
{shownHeadings.map((h, i) => {
|
||||
const Tag = (h.level || 'h2').toLowerCase()
|
||||
return (
|
||||
<Tag
|
||||
key={`h-${i}`}
|
||||
className={`section-heading section-heading--${Tag}`}
|
||||
dangerouslySetInnerHTML={{ __html: h.html }}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
|
||||
{shownImages.map((img, i) => (
|
||||
<figure key={`img-${i}`} className="section-figure">
|
||||
<img src={img.url} alt={img.alt || ''} loading="lazy" />
|
||||
</figure>
|
||||
))}
|
||||
|
||||
{shownParagraphs.map((p, i) => (
|
||||
<div
|
||||
key={`p-${i}`}
|
||||
className="section-paragraph"
|
||||
dangerouslySetInnerHTML={{ __html: p }}
|
||||
/>
|
||||
))}
|
||||
|
||||
{lists.length > 0 && (
|
||||
<div className="section-lists">
|
||||
{lists.map((l, i) => (
|
||||
<ul key={`l-${i}`} className="section-list">
|
||||
{l.map((item, j) => (
|
||||
<li key={j} dangerouslySetInnerHTML={{ __html: item }} />
|
||||
))}
|
||||
</ul>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{widgets.map((w, i) => (
|
||||
<Widget key={`w-${i}`} widget={w} />
|
||||
{blocks.map((block, i) => (
|
||||
<Block key={i} block={block} />
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function Widget({ widget }) {
|
||||
switch (widget.type) {
|
||||
function Block({ block }) {
|
||||
switch (block.type) {
|
||||
case 'heading': {
|
||||
const Tag = (block.level || 'h2').toLowerCase()
|
||||
return (
|
||||
<Tag
|
||||
className={`section-heading section-heading--${Tag}`}
|
||||
dangerouslySetInnerHTML={{ __html: sanitizeHtml(block.html) }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
case 'paragraph':
|
||||
return (
|
||||
<div
|
||||
className="section-paragraph"
|
||||
dangerouslySetInnerHTML={{ __html: sanitizeHtml(block.html) }}
|
||||
/>
|
||||
)
|
||||
|
||||
case 'quote':
|
||||
return (
|
||||
<blockquote
|
||||
className="section-quote"
|
||||
dangerouslySetInnerHTML={{ __html: sanitizeHtml(block.html) }}
|
||||
/>
|
||||
)
|
||||
|
||||
case 'image':
|
||||
return (
|
||||
<figure className="section-figure">
|
||||
<img src={block.url} alt={block.alt || ''} loading="lazy" />
|
||||
</figure>
|
||||
)
|
||||
|
||||
case 'banner':
|
||||
return (
|
||||
<div
|
||||
className="section-banner"
|
||||
role="img"
|
||||
aria-label={block.image?.alt || ''}
|
||||
style={{ backgroundImage: block.image?.url ? `url(${encodeURI(block.image.url)})` : undefined }}
|
||||
/>
|
||||
)
|
||||
|
||||
case 'list':
|
||||
return (
|
||||
<ul className="section-list">
|
||||
{block.items.map((item, j) => (
|
||||
<li key={j} dangerouslySetInnerHTML={{ __html: sanitizeHtml(item) }} />
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
|
||||
case 'grid':
|
||||
return (
|
||||
<div className="section-grid">
|
||||
{block.items.map((itemBlocks, j) => (
|
||||
<div className="section-grid-card" key={j}>
|
||||
<Content blocks={itemBlocks} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
||||
case 'accordion':
|
||||
return <Accordion items={widget.items} />
|
||||
return <Accordion items={block.items} />
|
||||
case 'tabs':
|
||||
return <Tabs items={widget.items} />
|
||||
return <Tabs items={block.items} />
|
||||
case 'carousel':
|
||||
return <Carousel slides={widget.slides} />
|
||||
return <Carousel slides={block.slides} />
|
||||
case 'slideshow':
|
||||
return <Slideshow slides={widget.slides} />
|
||||
return <Slideshow slides={block.slides} />
|
||||
case 'progressbar':
|
||||
return <ProgressBar {...widget} />
|
||||
return <ProgressBar {...block} />
|
||||
case 'fancy-text':
|
||||
return <FancyText {...widget} />
|
||||
return <FancyText {...block} />
|
||||
|
||||
case 'carousel-decorative':
|
||||
case 'nav-menu':
|
||||
// Sin contenido propio que mostrar (ver scripts/extract_site.py).
|
||||
return null
|
||||
|
||||
default:
|
||||
if (import.meta.env.DEV && widget.type?.startsWith('unhandled:')) {
|
||||
if (import.meta.env.DEV && block.type?.startsWith('unhandled:')) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('[Content] widget sin componente todavia:', widget.type, widget.settingsKeys)
|
||||
console.warn('[Content] bloque sin componente todavia:', block.type, block.settingsKeys)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default function Tabs({ items = [] }) {
|
||||
))}
|
||||
</div>
|
||||
<div className="pa-tabs-panel" role="tabpanel">
|
||||
<Content {...items[active]} />
|
||||
<Content blocks={items[active]?.blocks} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
http://remigracion.es/wp-content/uploads/2025/11/question-2.png
|
||||
http://remigracion.es/wp-content/uploads/2025/10/16254777787951-3-scaled-e1761564304440.jpg
|
||||
http://remigracion.es/wp-content/uploads/2025/10/6731734.jpg
|
||||
http://remigracion.es/wp-content/uploads/2025/10/costinvladalamariu_classroom_in_germany_full_of_16_year_old_p_756f463b-99b1-4251-9cff-dd0c3bbe2b4c_2-1456x816-1-e1760630796942.webp
|
||||
http://remigracion.es/wp-content/uploads/2025/10/الهجرة-الى-اوروبا.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Imagen2.png
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-11.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-12.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-15.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-18.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-19.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-20.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-22.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-24.jpg
|
||||
@@ -11,3 +16,7 @@ http://remigracion.es/wp-content/uploads/2026/02/placeholder-10.png
|
||||
http://remigracion.es/wp-content/uploads/2026/02/placeholder-11.png
|
||||
http://remigracion.es/wp-content/uploads/2026/02/placeholder-8.png
|
||||
http://remigracion.es/wp-content/uploads/2026/02/placeholder-9.png
|
||||
http://remigracion.es/wp-content/uploads/2026/02/zz1.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/zz2-10.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/zz3.jpg
|
||||
http://remigracion.es/wp-content/uploads/2026/02/zz4.jpg
|
||||
|
||||
+503
-268
File diff suppressed because one or more lines are too long
@@ -0,0 +1,20 @@
|
||||
import DOMPurify from 'dompurify'
|
||||
|
||||
// Los fragmentos HTML que llegan desde Elementor (titulos, parrafos, items
|
||||
// de lista, titulos de acordeon) se inyectan con dangerouslySetInnerHTML
|
||||
// porque conservan enfasis/color que forman parte del contenido original.
|
||||
// Antes de eso pasan por aqui: la lista de etiquetas/atributos permitidos
|
||||
// es deliberadamente pequena -- cubre solo el marcado de texto en linea que
|
||||
// realmente aparece en site.json (ver scripts/extract_site.py), nunca
|
||||
// scripts, iframes ni manejadores de eventos.
|
||||
const ALLOWED_TAGS = [
|
||||
'a', 'b', 'strong', 'i', 'em', 'u', 'span', 'br',
|
||||
'p', 'div', 'h2', 'h3', 'h4', 'h5', 'h6',
|
||||
'ul', 'ol', 'li', 'sup', 'sub',
|
||||
]
|
||||
const ALLOWED_ATTR = ['href', 'target', 'rel', 'style', 'dir', 'class']
|
||||
|
||||
export function sanitizeHtml(html) {
|
||||
if (!html) return ''
|
||||
return DOMPurify.sanitize(html, { ALLOWED_TAGS, ALLOWED_ATTR })
|
||||
}
|
||||
+4
-1
@@ -2,9 +2,12 @@ import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.jsx'
|
||||
import { Router } from './router/router.jsx'
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
<Router>
|
||||
<App />
|
||||
</Router>
|
||||
</StrictMode>,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import { useEffect } from 'react'
|
||||
import Section from '../components/Section'
|
||||
import siteData from '../content/site.json'
|
||||
|
||||
// Variantes visuales por anchor para romper la monotonia
|
||||
const VARIANTS = {
|
||||
'first-section': 'hero',
|
||||
significa: 'default',
|
||||
'inmigración_masiva': 'alt',
|
||||
detener_el_reemplazo_poblacional: 'default',
|
||||
que_podemoshacer: 'alt',
|
||||
precedentes_historicos: 'default',
|
||||
contacto: 'hero',
|
||||
}
|
||||
|
||||
// Orden en que aparecen en la pagina -- coincide con el orden del menu
|
||||
const SECTION_ORDER = [
|
||||
'first-section',
|
||||
'significa',
|
||||
'inmigración_masiva',
|
||||
'detener_el_reemplazo_poblacional',
|
||||
'que_podemoshacer',
|
||||
'precedentes_historicos',
|
||||
'contacto',
|
||||
]
|
||||
|
||||
export default function Home() {
|
||||
const byAnchor = Object.fromEntries(
|
||||
siteData.sections.map((s) => [s.anchor, s])
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
// carga directa de / con un #ancla en la URL (o navegacion desde otra
|
||||
// pagina que ya trae el hash) -- el click normal en el navbar lo
|
||||
// resuelve el propio Router al navegar
|
||||
if (window.location.hash) {
|
||||
const id = window.location.hash.slice(1)
|
||||
requestAnimationFrame(() => {
|
||||
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' })
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
{SECTION_ORDER.map((anchor) => {
|
||||
const s = byAnchor[anchor]
|
||||
if (!s) return null
|
||||
return (
|
||||
<Section
|
||||
key={anchor}
|
||||
section={s}
|
||||
variant={VARIANTS[anchor] || 'default'}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import Content from '../components/content/Content'
|
||||
import siteData from '../content/site.json'
|
||||
|
||||
// Paginas legales (cookies, aviso legal): mismo renderer de contenido que
|
||||
// las secciones de la home (Content.jsx), pero sin truncar -- aqui el texto
|
||||
// completo es el contenido, no un resumen.
|
||||
export default function LegalPage({ pageKey }) {
|
||||
const page = siteData.pages?.[pageKey]
|
||||
|
||||
if (!page) {
|
||||
return (
|
||||
<section className="section section--default">
|
||||
<div className="section-inner">
|
||||
<h2 className="section-heading section-heading--h2">Pagina no disponible</h2>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="section section--default">
|
||||
<div className="section-inner">
|
||||
<Content blocks={page.blocks} />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Link } from '../router/router'
|
||||
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<section className="section section--default">
|
||||
<div className="section-inner">
|
||||
<h2 className="section-heading section-heading--h2">Pagina no encontrada</h2>
|
||||
<div className="section-paragraph">
|
||||
<p>
|
||||
<Link to="/">Volver al inicio</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createContext, useCallback, useContext, useEffect, useState } from 'react'
|
||||
|
||||
// Router minimalista sin dependencias externas: para 3 rutas estaticas sin
|
||||
// parametros ni carga de datos, react-router-dom seria mucho mas de lo que
|
||||
// este sitio necesita. Cubre lo esencial: navegacion con la History API,
|
||||
// <Link> que no recarga la pagina, y saltar a anclas (#seccion) tanto en la
|
||||
// home como al volver a ella desde otra ruta.
|
||||
|
||||
const RouterContext = createContext(null)
|
||||
|
||||
function normalize(pathname) {
|
||||
if (pathname.length > 1 && pathname.endsWith('/')) {
|
||||
return pathname.slice(0, -1)
|
||||
}
|
||||
return pathname || '/'
|
||||
}
|
||||
|
||||
function scrollToHash(hash) {
|
||||
if (!hash) return
|
||||
const id = hash.replace(/^#/, '')
|
||||
// requestAnimationFrame: deja que la ruta/seccion nueva termine de montar
|
||||
// antes de medir su posicion en pantalla.
|
||||
requestAnimationFrame(() => {
|
||||
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' })
|
||||
})
|
||||
}
|
||||
|
||||
export function Router({ children }) {
|
||||
const [pathname, setPathname] = useState(() => normalize(window.location.pathname))
|
||||
|
||||
useEffect(() => {
|
||||
const onPopState = () => {
|
||||
setPathname(normalize(window.location.pathname))
|
||||
if (window.location.hash) scrollToHash(window.location.hash)
|
||||
}
|
||||
window.addEventListener('popstate', onPopState)
|
||||
return () => window.removeEventListener('popstate', onPopState)
|
||||
}, [])
|
||||
|
||||
const navigate = useCallback((to) => {
|
||||
const [rawPath, hash] = to.split('#')
|
||||
const target = normalize(rawPath || '/')
|
||||
const prevPathname = normalize(window.location.pathname)
|
||||
const nextUrl = hash ? `${target}#${hash}` : target
|
||||
const prevUrl = `${prevPathname}${window.location.hash}`
|
||||
|
||||
if (nextUrl !== prevUrl) {
|
||||
window.history.pushState({}, '', nextUrl)
|
||||
}
|
||||
if (target !== prevPathname) {
|
||||
setPathname(target)
|
||||
}
|
||||
|
||||
if (hash) {
|
||||
scrollToHash(hash)
|
||||
} else {
|
||||
window.scrollTo({ top: 0 })
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<RouterContext.Provider value={{ pathname, navigate }}>
|
||||
{children}
|
||||
</RouterContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useRouter() {
|
||||
const ctx = useContext(RouterContext)
|
||||
if (!ctx) throw new Error('useRouter debe usarse dentro de <Router>')
|
||||
return ctx
|
||||
}
|
||||
|
||||
export function Link({ to, children, ...rest }) {
|
||||
const { navigate } = useRouter()
|
||||
const handleClick = (e) => {
|
||||
// deja pasar los clicks modificados (abrir en pestana nueva, etc.) tal
|
||||
// cual los manejaria un <a> normal
|
||||
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
||||
return
|
||||
}
|
||||
e.preventDefault()
|
||||
navigate(to)
|
||||
}
|
||||
return (
|
||||
<a href={to} onClick={handleClick} {...rest}>
|
||||
{children}
|
||||
</a>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user