From 1825dfae4edfccf0c73773c3dfff6fbdccce94bb Mon Sep 17 00:00:00 2001 From: Renato Date: Tue, 4 Aug 2026 17:26:33 +0800 Subject: [PATCH] gate +18 con cookie de 1 dia (web + links page) --- src/app/(public)/layout.tsx | 3 ++ src/components/age-gate.tsx | 65 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/components/age-gate.tsx diff --git a/src/app/(public)/layout.tsx b/src/app/(public)/layout.tsx index 0664e0b..162c159 100644 --- a/src/app/(public)/layout.tsx +++ b/src/app/(public)/layout.tsx @@ -1,11 +1,14 @@ import Link from "next/link" import { Image, Search } from "lucide-react" import { SITE_NAME, SITE_TAGLINE, SITE_LINKS } from "@/lib/site" +import { AgeGate } from "@/components/age-gate" // Header del sitio público: búsqueda pública (SQLite) + logo. export default function PublicLayout({ children }: { children: React.ReactNode }) { return ( <> + {/* Gate +18 con persistencia de 1 día */} +
diff --git a/src/components/age-gate.tsx b/src/components/age-gate.tsx new file mode 100644 index 0000000..9af12cd --- /dev/null +++ b/src/components/age-gate.tsx @@ -0,0 +1,65 @@ +"use client" + +import { useEffect, useState } from "react" + +const COOKIE_NAME = "ws_age_ok" +const COOKIE_DAYS = 1 + +// Gate de contenidos +18: se muestra hasta que el usuario confirma ser mayor. +// Persistencia: cookie de 1 día. Si dice ser menor -> Google. +export function AgeGate() { + const [show, setShow] = useState(false) + + useEffect(() => { + const ok = document.cookie + .split(";") + .some((c) => c.trim().startsWith(`${COOKIE_NAME}=`)) + setShow(!ok) + }, []) + + const confirmAdult = () => { + const d = new Date() + d.setTime(d.getTime() + COOKIE_DAYS * 24 * 60 * 60 * 1000) + document.cookie = `${COOKIE_NAME}=1; expires=${d.toUTCString()}; path=/; max-age=${COOKIE_DAYS * 24 * 60 * 60}` + setShow(false) + } + + const deny = () => { + window.location.href = "https://www.google.com/" + } + + if (!show) return null + + return ( +
+ {/* fondo */} +
+
+
+ 18+ +
+
+

Contenido para adultos

+

+ Este sitio contiene mangas con contenido explícito para mayores de 18 años. +

+
+
+ + +
+
+
+ ) +} \ No newline at end of file