Compare commits
5
Commits
027bdebd1e
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8e9fd0c4c | ||
|
|
83e6d9305d | ||
|
|
f7135c4fb9 | ||
|
|
acd9265ecc | ||
|
|
7af3e36de4 |
@@ -2,17 +2,21 @@
|
|||||||
#
|
#
|
||||||
# El runner self-hosted de Gitea corre como root en el mismo host que sirve
|
# El runner self-hosted de Gitea corre como root en el mismo host que sirve
|
||||||
# git.localesp.es y remigracion.jumpingcrab.com, así que no hay SSH ni
|
# git.localesp.es y remigracion.jumpingcrab.com, así que no hay SSH ni
|
||||||
# secretos: el job compila y luego ejecuta scripts/deploy.sh.
|
# secretos: el job compila y, si toca desplegar, ejecuta scripts/deploy.sh.
|
||||||
#
|
#
|
||||||
# Destino: /opt/remigracion/dist + vhost nginx HTTP (sin TLS: el DNS de
|
# En pull_request el pipeline corre ENTERO menos el despliegue: sirve para
|
||||||
# remigracion.jumpingcrab.com no permite emitir Let's Encrypt). El entorno es
|
# validar el build y las comprobaciones antes de mergear. Sólo se despliega
|
||||||
# privado: noindex por cabecera, meta robots y robots.txt.
|
# en push a master (o con workflow_dispatch).
|
||||||
name: deploy
|
#
|
||||||
|
# Destino: /opt/remigracion/dist + vhost nginx HTTP. Entorno privado:
|
||||||
|
# noindex por cabecera, meta robots y robots.txt.
|
||||||
|
name: pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
@@ -20,7 +24,8 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
build:
|
||||||
|
name: Build + comprobaciones
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
@@ -41,6 +46,32 @@ jobs:
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
grep -qi 'name="robots"' dist/index.html
|
grep -qi 'name="robots"' dist/index.html
|
||||||
grep -q 'Disallow: /' dist/robots.txt
|
grep -q 'Disallow: /' dist/robots.txt
|
||||||
|
echo "OK: dist/index.html lleva meta robots y dist/robots.txt bloquea todo"
|
||||||
|
|
||||||
|
- name: Comprobar que el script de despliegue es válido
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
bash -n scripts/deploy.sh
|
||||||
|
echo "OK: scripts/deploy.sh sin errores de sintaxis"
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: Desplegar en el host
|
||||||
|
runs-on: self-hosted
|
||||||
|
needs: build
|
||||||
|
# Clave: en PRs no se despliega nada; sólo se valida el pipeline.
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
timeout-minutes: 15
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Dependencias
|
||||||
|
shell: bash
|
||||||
|
run: npm ci --no-audit --no-fund
|
||||||
|
|
||||||
|
- name: Build (vite)
|
||||||
|
shell: bash
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
- name: Desplegar en el host
|
- name: Desplegar en el host
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -60,14 +60,11 @@ El JSON tiene tres claves:
|
|||||||
|
|
||||||
## Despliegue
|
## Despliegue
|
||||||
|
|
||||||
Entorno de previsualización privado en **<https://remigracion.jumpingcrab.com/>**
|
Entorno de previsualización privado en **<http://remigracion.jumpingcrab.com/>**
|
||||||
(mismo host que `localesp.es` y `git.localesp.es`).
|
(mismo host que `localesp.es` y `git.localesp.es`).
|
||||||
|
|
||||||
- **HTTP y HTTPS:** el vhost escucha en 80 y 443 (mismo `server` block, así
|
- **Sin TLS a propósito:** el DNS de `remigracion.jumpingcrab.com` no permite
|
||||||
que las reglas anti-indexación no se duplican). Certificado Let's Encrypt
|
emitir un certificado Let's Encrypt, así que se sirve sólo por HTTP.
|
||||||
emitido con webroot en `/var/www/letsencrypt` y renovado por
|
|
||||||
`certbot-renew.timer`; el `--deploy-hook` recarga nginx. El puerto 80 no
|
|
||||||
redirige a 443: sirve la app igual.
|
|
||||||
- **No indexable:** el entorno no debe aparecer en buscadores, agregadores ni
|
- **No indexable:** el entorno no debe aparecer en buscadores, agregadores ni
|
||||||
crawlers de IA. Se aplica en tres capas independientes:
|
crawlers de IA. Se aplica en tres capas independientes:
|
||||||
1. nginx devuelve `403` a los user-agents de rastreadores conocidos.
|
1. nginx devuelve `403` a los user-agents de rastreadores conocidos.
|
||||||
@@ -76,10 +73,19 @@ Entorno de previsualización privado en **<https://remigracion.jumpingcrab.com/>
|
|||||||
3. `public/robots.txt` (`Disallow: /`) y `<meta name="robots">` en
|
3. `public/robots.txt` (`Disallow: /`) y `<meta name="robots">` en
|
||||||
`index.html`.
|
`index.html`.
|
||||||
|
|
||||||
Automatización: `.gitea/workflows/deploy.yml` compila y publica en cada push a
|
Automatización: `.gitea/workflows/deploy.yml` (workflow `pipeline`) tiene dos
|
||||||
`master` (también se puede lanzar a mano con `workflow_dispatch`). El runner
|
jobs:
|
||||||
self-hosted de Gitea corre como root en el mismo host, así que el job no
|
|
||||||
necesita SSH ni secretos.
|
- **`build`** (siempre): `npm ci`, `npm run build`, comprobación de que el
|
||||||
|
bundle lleva `meta robots` + `robots.txt`, y `bash -n` del script de deploy.
|
||||||
|
- **`deploy`** (sólo si NO es una PR): repite el build y ejecuta
|
||||||
|
`scripts/deploy.sh`.
|
||||||
|
|
||||||
|
En las **pull requests** el pipeline corre entero menos el despliegue, así que
|
||||||
|
sirve para verificar el CI antes de mergear. Se despliega en cada push a
|
||||||
|
`master` y también a mano con `workflow_dispatch`. El runner self-hosted de
|
||||||
|
Gitea corre como root en el mismo host, así que el job no necesita SSH ni
|
||||||
|
secretos.
|
||||||
|
|
||||||
Artefactos y servicios en el host (mismo patrón que
|
Artefactos y servicios en el host (mismo patrón que
|
||||||
`prototipo-yb01-ef.localesp.es`):
|
`prototipo-yb01-ef.localesp.es`):
|
||||||
@@ -88,8 +94,6 @@ Artefactos y servicios en el host (mismo patrón que
|
|||||||
|---|---|
|
|---|---|
|
||||||
| Build estático (raíz de nginx) | `/opt/remigracion/dist` |
|
| Build estático (raíz de nginx) | `/opt/remigracion/dist` |
|
||||||
| vhost nginx (fuente en `deploy/nginx.conf`) | `/etc/nginx/conf.d/remigracion.jumpingcrab.com.conf` |
|
| vhost nginx (fuente en `deploy/nginx.conf`) | `/etc/nginx/conf.d/remigracion.jumpingcrab.com.conf` |
|
||||||
| Certificado Let's Encrypt | `/etc/letsencrypt/live/remigracion.jumpingcrab.com/` |
|
|
||||||
| Webroot ACME | `/var/www/letsencrypt` |
|
|
||||||
| Script de despliegue | `scripts/deploy.sh` |
|
| Script de despliegue | `scripts/deploy.sh` |
|
||||||
|
|
||||||
Despliegue manual:
|
Despliegue manual:
|
||||||
@@ -99,10 +103,9 @@ npm ci && npm run build
|
|||||||
sudo bash scripts/deploy.sh
|
sudo bash scripts/deploy.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
El script sincroniza `dist/`, crea el webroot ACME, etiqueta el árbol para
|
El script sincroniza `dist/`, etiqueta el árbol para SELinux
|
||||||
SELinux (`httpd_sys_content_t`), instala el vhost si cambió (con rollback si
|
(`httpd_sys_content_t`), instala el vhost si cambió (con rollback si
|
||||||
`nginx -t` falla), recarga nginx y verifica `200` en HTTP y HTTPS (validando
|
`nginx -t` falla), recarga nginx y verifica `200` + `X-Robots-Tag`.
|
||||||
el certificado) más la cabecera `X-Robots-Tag`.
|
|
||||||
|
|
||||||
## Próximos pasos
|
## Próximos pasos
|
||||||
|
|
||||||
|
|||||||
+4
-21
@@ -1,27 +1,18 @@
|
|||||||
# remigracion.jumpingcrab.com — entorno privado de previsualización.
|
# remigracion.jumpingcrab.com — entorno privado de previsualización.
|
||||||
#
|
#
|
||||||
# Sirve el build estático de Vite desde /opt/remigracion/dist por HTTP y HTTPS
|
# Sin TLS a propósito: el DNS de este dominio no permite emitir un certificado
|
||||||
# en el mismo server block. El certificado lo emite certbot con webroot en
|
# Let's Encrypt, así que se sirve sólo por HTTP.
|
||||||
# /var/www/letsencrypt y se renueva con el timer del sistema (el deploy-hook
|
|
||||||
# del certificado recarga nginx).
|
|
||||||
#
|
#
|
||||||
# No indexación (objetivo doble):
|
# No indexación (objetivo doble):
|
||||||
# 1. 403 en el borde a los rastreadores conocidos, antes de servir nada.
|
# 1. Cabecera X-Robots-Tag en TODAS las respuestas (incluidos 4xx/5xx).
|
||||||
# 2. Cabecera X-Robots-Tag en TODAS las respuestas (incluidos 4xx/5xx).
|
# 2. 403 en el borde a los rastreadores conocidos, antes de servir nada.
|
||||||
# El bundle también declara <meta name="robots"> y sirve un robots.txt
|
# El bundle también declara <meta name="robots"> y sirve un robots.txt
|
||||||
# con "Disallow: /" (ver public/robots.txt e index.html).
|
# con "Disallow: /" (ver public/robots.txt e index.html).
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
listen 443 ssl http2;
|
|
||||||
listen [::]:443 ssl http2;
|
|
||||||
server_name remigracion.jumpingcrab.com;
|
server_name remigracion.jumpingcrab.com;
|
||||||
|
|
||||||
ssl_certificate /etc/letsencrypt/live/remigracion.jumpingcrab.com/fullchain.pem;
|
|
||||||
ssl_certificate_key /etc/letsencrypt/live/remigracion.jumpingcrab.com/privkey.pem;
|
|
||||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
|
||||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
|
||||||
|
|
||||||
root /opt/remigracion/dist;
|
root /opt/remigracion/dist;
|
||||||
index index.html;
|
index index.html;
|
||||||
charset utf-8;
|
charset utf-8;
|
||||||
@@ -35,14 +26,6 @@ server {
|
|||||||
return 403;
|
return 403;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Validación ACME de certbot. Vive fuera del árbol desplegado para que el
|
|
||||||
# 'rsync --delete' del deploy no borre el challenge a mitad de una renovación.
|
|
||||||
location ^~ /.well-known/acme-challenge/ {
|
|
||||||
root /var/www/letsencrypt;
|
|
||||||
default_type "text/plain";
|
|
||||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
|
||||||
}
|
|
||||||
|
|
||||||
# robots.txt generado aquí mismo: el deploy no depende del build para esto.
|
# robots.txt generado aquí mismo: el deploy no depende del build para esto.
|
||||||
location = /robots.txt {
|
location = /robots.txt {
|
||||||
add_header Content-Type "text/plain; charset=utf-8" always;
|
add_header Content-Type "text/plain; charset=utf-8" always;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"dompurify": "^3.4.14",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1"
|
"react-dom": "^18.3.1"
|
||||||
},
|
},
|
||||||
|
|||||||
+9
-35
@@ -16,8 +16,6 @@ APP_HOST="remigracion.jumpingcrab.com"
|
|||||||
DEPLOY_ROOT="/opt/remigracion"
|
DEPLOY_ROOT="/opt/remigracion"
|
||||||
VHOST_PATH="/etc/nginx/conf.d/remigracion.jumpingcrab.com.conf"
|
VHOST_PATH="/etc/nginx/conf.d/remigracion.jumpingcrab.com.conf"
|
||||||
BACKUP_DIR="/var/backups/nginx"
|
BACKUP_DIR="/var/backups/nginx"
|
||||||
TLS_CERT_PATH="/etc/letsencrypt/live/remigracion.jumpingcrab.com/fullchain.pem"
|
|
||||||
ACME_WEBROOT="/var/www/letsencrypt"
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0" >&2
|
echo "Usage: $0" >&2
|
||||||
@@ -57,17 +55,6 @@ artifact::require_build() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# El vhost sirve HTTP y HTTPS: sin certificado nginx -t fallaría.
|
|
||||||
tls::require_certificate() {
|
|
||||||
if [ ! -f "$TLS_CERT_PATH" ]; then
|
|
||||||
fail "falta el certificado $TLS_CERT_PATH — emitelo con: certbot certonly --webroot -w $ACME_WEBROOT -d $APP_HOST --deploy-hook 'systemctl reload nginx'"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
acme::prepare_webroot() {
|
|
||||||
mkdir -p "$ACME_WEBROOT"
|
|
||||||
}
|
|
||||||
|
|
||||||
artifact::sync() {
|
artifact::sync() {
|
||||||
local root="$1"
|
local root="$1"
|
||||||
|
|
||||||
@@ -153,23 +140,14 @@ nginx::reload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
http::expect() {
|
http::expect() {
|
||||||
local scheme="$1"
|
local url="$1"
|
||||||
local url="$2"
|
local expected="$2"
|
||||||
local expected="$3"
|
|
||||||
local port="80"
|
|
||||||
local attempt
|
local attempt
|
||||||
local code
|
local code
|
||||||
|
|
||||||
if [ "$scheme" = "https" ]; then
|
|
||||||
port="443"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Se resuelve el dominio a loopback: prueba el vhost correcto y, en HTTPS,
|
|
||||||
# la cadena y el nombre del certificado (sin -k).
|
|
||||||
# nginx recarga en segundo plano: se reintenta antes de dar el deploy por fallido.
|
# nginx recarga en segundo plano: se reintenta antes de dar el deploy por fallido.
|
||||||
for attempt in $(seq 1 15); do
|
for attempt in $(seq 1 15); do
|
||||||
code="$(curl -s -o /dev/null -m 5 -w '%{http_code}' \
|
code="$(curl -s -o /dev/null -m 5 -w '%{http_code}' -H "Host: $APP_HOST" "$url" || true)"
|
||||||
--resolve "$APP_HOST:$port:127.0.0.1" "$url" 2>/dev/null || true)"
|
|
||||||
if [ "$code" = "$expected" ]; then
|
if [ "$code" = "$expected" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -182,16 +160,14 @@ http::expect() {
|
|||||||
http::verify() {
|
http::verify() {
|
||||||
local headers
|
local headers
|
||||||
|
|
||||||
# HTTPS valida además la cadena y el nombre del certificado (sin -k).
|
http::expect "http://127.0.0.1/" "200"
|
||||||
http::expect "http" "http://$APP_HOST/" "200"
|
http::expect "http://127.0.0.1/robots.txt" "200"
|
||||||
http::expect "https" "https://$APP_HOST/" "200"
|
|
||||||
http::expect "http" "http://$APP_HOST/robots.txt" "200"
|
|
||||||
|
|
||||||
headers="$(curl -sI -m 10 --resolve "$APP_HOST:443:127.0.0.1" "https://$APP_HOST/" | tr -d '\r')"
|
headers="$(curl -sI -m 10 -H "Host: $APP_HOST" "http://127.0.0.1/" | tr -d '\r')"
|
||||||
if ! grep -qi '^X-Robots-Tag:.*noindex' <<< "$headers"; then
|
if ! grep -qi '^X-Robots-Tag:.*noindex' <<< "$headers"; then
|
||||||
fail "falta la cabecera X-Robots-Tag: noindex en la respuesta HTTPS"
|
fail "falta la cabecera X-Robots-Tag: noindex en la respuesta"
|
||||||
fi
|
fi
|
||||||
log "verificado: HTTP y HTTPS 200, certificado válido, X-Robots-Tag: noindex"
|
log "verificado: HTTP 200 y X-Robots-Tag: noindex"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
@@ -202,10 +178,8 @@ main() {
|
|||||||
host::require_root
|
host::require_root
|
||||||
host::require_tools
|
host::require_tools
|
||||||
artifact::require_build "$root"
|
artifact::require_build "$root"
|
||||||
tls::require_certificate
|
|
||||||
|
|
||||||
artifact::sync "$root"
|
artifact::sync "$root"
|
||||||
acme::prepare_webroot
|
|
||||||
selinux::label
|
selinux::label
|
||||||
|
|
||||||
if vhost::install "$root"; then
|
if vhost::install "$root"; then
|
||||||
@@ -213,7 +187,7 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
http::verify
|
http::verify
|
||||||
log "LISTO: https://$APP_HOST/ (no indexable)"
|
log "LISTO: http://$APP_HOST/ (sin TLS, no indexable)"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
+56
@@ -173,6 +173,62 @@ img {
|
|||||||
margin: 0.5rem 0;
|
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 ------- */
|
/* ------- Footer ------- */
|
||||||
.site-footer {
|
.site-footer {
|
||||||
background: var(--color-bg-dark);
|
background: var(--color-bg-dark);
|
||||||
|
|||||||
+11
-38
@@ -1,52 +1,25 @@
|
|||||||
import Navbar from './components/Navbar'
|
import Navbar from './components/Navbar'
|
||||||
import Section from './components/Section'
|
|
||||||
import Footer from './components/Footer'
|
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'
|
import './App.css'
|
||||||
|
|
||||||
// Variantes visuales por anchor para romper la monotonía
|
const ROUTES = {
|
||||||
const VARIANTS = {
|
'/': () => <Home />,
|
||||||
'first-section': 'hero',
|
'/informacion-sobre-las-cookies': () => <LegalPage pageKey="cookies" />,
|
||||||
significa: 'default',
|
'/aviso-legal-y-proteccion-de-datos': () => <LegalPage pageKey="avisoLegal" />,
|
||||||
'inmigración_masiva': 'alt',
|
|
||||||
detener_el_reemplazo_poblacional: 'default',
|
|
||||||
que_podemoshacer: 'alt',
|
|
||||||
precedentes_historicos: 'default',
|
|
||||||
contacto: 'hero',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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() {
|
function App() {
|
||||||
const byAnchor = Object.fromEntries(
|
const { pathname } = useRouter()
|
||||||
siteData.sections.map((s) => [s.anchor, s])
|
const renderPage = ROUTES[pathname]
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Navbar />
|
<Navbar />
|
||||||
<main>
|
<main>{renderPage ? renderPage() : <NotFound />}</main>
|
||||||
{SECTION_ORDER.map((anchor) => {
|
|
||||||
const s = byAnchor[anchor]
|
|
||||||
if (!s) return null
|
|
||||||
return (
|
|
||||||
<Section
|
|
||||||
key={anchor}
|
|
||||||
section={s}
|
|
||||||
variant={VARIANTS[anchor] || 'default'}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</main>
|
|
||||||
<Footer />
|
<Footer />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import { Link } from '../router/router'
|
||||||
import siteData from '../content/site.json'
|
import siteData from '../content/site.json'
|
||||||
|
|
||||||
export default function Footer() {
|
export default function Footer() {
|
||||||
const { site } = siteData
|
const { site, menus } = siteData
|
||||||
|
const footerLinks = menus?.footer || []
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<footer className="site-footer" id="contacto-footer">
|
<footer className="site-footer" id="contacto-footer">
|
||||||
<div className="site-footer-inner">
|
<div className="site-footer-inner">
|
||||||
@@ -10,12 +13,11 @@ export default function Footer() {
|
|||||||
{site.description} — Todos los derechos reservados
|
{site.description} — Todos los derechos reservados
|
||||||
</p>
|
</p>
|
||||||
<ul className="site-footer-links">
|
<ul className="site-footer-links">
|
||||||
<li>
|
{footerLinks.map((item) => (
|
||||||
<a href="/informacion-sobre-las-cookies">Cookies</a>
|
<li key={item.order}>
|
||||||
</li>
|
<Link to={item.url}>{item.title}</Link>
|
||||||
<li>
|
</li>
|
||||||
<a href="/aviso-legal-y-proteccion-de-datos">Aviso legal</a>
|
))}
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,19 +1,30 @@
|
|||||||
|
import { Link, useRouter } from '../router/router'
|
||||||
import siteData from '../content/site.json'
|
import siteData from '../content/site.json'
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
const { site, menu } = siteData
|
const { site, menus } = siteData
|
||||||
|
const { pathname } = useRouter()
|
||||||
|
const items = menus?.principal || []
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="nav">
|
<nav className="nav">
|
||||||
<div className="nav-inner">
|
<div className="nav-inner">
|
||||||
<a href="#first-section" className="brand">
|
<Link to="/" className="brand">
|
||||||
{site.name}
|
{site.name}
|
||||||
</a>
|
</Link>
|
||||||
<ul className="nav-links">
|
<ul className="nav-links">
|
||||||
{menu.map((item) => (
|
{items.map((item) => {
|
||||||
<li key={item.order}>
|
// los items del menu principal son anclas de la home (#seccion);
|
||||||
<a href={item.url}>{item.title}</a>
|
// desde otra pagina hay que volver primero a "/"
|
||||||
</li>
|
const to = item.url.startsWith('#') && pathname !== '/'
|
||||||
))}
|
? `/${item.url}`
|
||||||
|
: item.url
|
||||||
|
return (
|
||||||
|
<li key={item.order}>
|
||||||
|
<Link to={to}>{item.title}</Link>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export default function Section({ section, variant = 'default' }) {
|
|||||||
return (
|
return (
|
||||||
<section id={anchor} className={`section section--${variant}`}>
|
<section id={anchor} className={`section section--${variant}`}>
|
||||||
<div className="section-inner">
|
<div className="section-inner">
|
||||||
<Content {...section} truncate />
|
<Content blocks={section.blocks} />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import Content from './Content'
|
import Content from './Content'
|
||||||
|
import { sanitizeHtml } from '../../lib/sanitize'
|
||||||
|
|
||||||
export default function Accordion({ items = [] }) {
|
export default function Accordion({ items = [] }) {
|
||||||
const [openIndex, setOpenIndex] = useState(null)
|
const [openIndex, setOpenIndex] = useState(null)
|
||||||
@@ -17,14 +18,14 @@ export default function Accordion({ items = [] }) {
|
|||||||
aria-expanded={isOpen}
|
aria-expanded={isOpen}
|
||||||
onClick={() => setOpenIndex(isOpen ? null : i)}
|
onClick={() => setOpenIndex(isOpen ? null : i)}
|
||||||
>
|
>
|
||||||
<span dangerouslySetInnerHTML={{ __html: item.title }} />
|
<span dangerouslySetInnerHTML={{ __html: sanitizeHtml(item.title) }} />
|
||||||
<span className="pa-accordion-icon" aria-hidden="true">
|
<span className="pa-accordion-icon" aria-hidden="true">
|
||||||
{isOpen ? '−' : '+'}
|
{isOpen ? '−' : '+'}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{isOpen && (
|
{isOpen && (
|
||||||
<div className="pa-accordion-panel">
|
<div className="pa-accordion-panel">
|
||||||
<Content {...item} />
|
<Content blocks={item.blocks} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default function Carousel({ slides = [] }) {
|
|||||||
<div className="pa-carousel-track" ref={trackRef}>
|
<div className="pa-carousel-track" ref={trackRef}>
|
||||||
{slides.map((slide, i) => (
|
{slides.map((slide, i) => (
|
||||||
<div key={i} className="pa-carousel-slide">
|
<div key={i} className="pa-carousel-slide">
|
||||||
<Content {...slide} />
|
<Content blocks={slide.blocks} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import './content.css'
|
import './content.css'
|
||||||
|
import { sanitizeHtml } from '../../lib/sanitize'
|
||||||
import Accordion from './Accordion'
|
import Accordion from './Accordion'
|
||||||
import Tabs from './Tabs'
|
import Tabs from './Tabs'
|
||||||
import Carousel from './Carousel'
|
import Carousel from './Carousel'
|
||||||
@@ -7,95 +8,118 @@ import ProgressBar from './ProgressBar'
|
|||||||
import FancyText from './FancyText'
|
import FancyText from './FancyText'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderiza un bloque de contenido extraido de Elementor: encabezados,
|
* Renderiza una lista ORDENADA de bloques extraidos de Elementor (ver
|
||||||
* parrafos, imagenes, listas y widgets especiales (acordeon, tabs,
|
* extract_container() en scripts/extract_site.py): encabezados, parrafos,
|
||||||
* carrusel, slideshow, barra de progreso, texto animado).
|
* 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,
|
* Se usa tanto para una seccion completa de la home/paginas legales como,
|
||||||
* recursivamente, para el contenido anidado dentro de un panel de
|
* recursivamente, para el contenido anidado dentro de una tarjeta de
|
||||||
* acordeon/tab/slide de carrusel (por eso "truncate" es false por defecto:
|
* rejilla o un panel de acordeon/tab/slide de carrusel.
|
||||||
* los paneles anidados suelen ser pequenos y no conviene recortarlos).
|
|
||||||
*/
|
*/
|
||||||
export default function Content({
|
export default function Content({ blocks = [] }) {
|
||||||
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
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{shownHeadings.map((h, i) => {
|
{blocks.map((block, i) => (
|
||||||
const Tag = (h.level || 'h2').toLowerCase()
|
<Block key={i} block={block} />
|
||||||
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} />
|
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Widget({ widget }) {
|
function Block({ block }) {
|
||||||
switch (widget.type) {
|
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':
|
case 'accordion':
|
||||||
return <Accordion items={widget.items} />
|
return <Accordion items={block.items} />
|
||||||
case 'tabs':
|
case 'tabs':
|
||||||
return <Tabs items={widget.items} />
|
return <Tabs items={block.items} />
|
||||||
case 'carousel':
|
case 'carousel':
|
||||||
return <Carousel slides={widget.slides} />
|
return <Carousel slides={block.slides} />
|
||||||
case 'slideshow':
|
case 'slideshow':
|
||||||
return <Slideshow slides={widget.slides} />
|
return <Slideshow slides={block.slides} />
|
||||||
case 'progressbar':
|
case 'progressbar':
|
||||||
return <ProgressBar {...widget} />
|
return <ProgressBar {...block} />
|
||||||
case 'fancy-text':
|
case 'fancy-text':
|
||||||
return <FancyText {...widget} />
|
return <FancyText {...block} />
|
||||||
|
|
||||||
case 'carousel-decorative':
|
case 'carousel-decorative':
|
||||||
case 'nav-menu':
|
case 'nav-menu':
|
||||||
// Sin contenido propio que mostrar (ver scripts/extract_site.py).
|
// Sin contenido propio que mostrar (ver scripts/extract_site.py).
|
||||||
return null
|
return null
|
||||||
|
|
||||||
default:
|
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
|
// 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
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default function Tabs({ items = [] }) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="pa-tabs-panel" role="tabpanel">
|
<div className="pa-tabs-panel" role="tabpanel">
|
||||||
<Content {...items[active]} />
|
<Content blocks={items[active]?.blocks} />
|
||||||
</div>
|
</div>
|
||||||
</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/Imagen2.png
|
||||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-11.jpg
|
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-15.jpg
|
||||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-18.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-20.jpg
|
||||||
http://remigracion.es/wp-content/uploads/2026/02/Sin-titulo-22.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
|
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-11.png
|
||||||
http://remigracion.es/wp-content/uploads/2026/02/placeholder-8.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/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 { createRoot } from 'react-dom/client'
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import App from './App.jsx'
|
import App from './App.jsx'
|
||||||
|
import { Router } from './router/router.jsx'
|
||||||
|
|
||||||
createRoot(document.getElementById('root')).render(
|
createRoot(document.getElementById('root')).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<App />
|
<Router>
|
||||||
|
<App />
|
||||||
|
</Router>
|
||||||
</StrictMode>,
|
</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