/* === Shared: constants, Header, Footer, building blocks === */ const SITE = { domain: "vinodepasto.com", buyUrl: "https://bodegasbaron.es/collections/tienda-online?filter.p.tag=Paranormal&utm_source=vinodepasto.com&utm_medium=referral&utm_campaign=paranormal_pasto10", buyUrlBlanco: "https://bodegasbaron.es/products/vino-blanco-paranormal?utm_source=vinodepasto.com&utm_medium=referral&utm_campaign=paranormal_blanco_pasto10", buyUrlOxidativo: "https://bodegasbaron.es/products/vino-blanco-oxidativo-paranormal-2023?utm_source=vinodepasto.com&utm_medium=referral&utm_campaign=paranormal_oxidativo_pasto10", coupon: "PASTO10", }; const NAV = [ { id: "home", label: "Inicio", path: "/" }, { id: "que-es", label: "Vino de Pasto", path: "/que-es-vino-de-pasto" }, { id: "paranormal", label: "Paranormal", path: "/paranormal" }, { id: "bodega", label: "Bodegas Barón", path: "/bodegas-baron" }, { id: "blog", label: "Cuaderno", path: "/blog" }, ]; const NAV_EN = [ { id: "home", label: "Home", path: "/en" }, { id: "que-es", label: "Vino de Pasto", path: "/en/wine-de-pasto" }, { id: "paranormal", label: "Paranormal", path: "/en/paranormal" }, { id: "bodega", label: "Bodegas Barón", path: "/en/bodegas-baron" }, { id: "blog", label: "Notebook", path: "/en/notebook" }, ]; function currentLang() { return window.location.pathname.startsWith("/en") ? "en" : "es"; } function langPath(path) { return currentLang() === "en" ? "/en" + (path === "/" ? "" : path) : path; } function isExternalUrl(to) { return typeof to === "string" && /^(https?:)?\/\//.test(to); } function switchLangPath() { const p = window.location.pathname.replace(/\/$/, "") || "/"; if (p === "/en") return "/"; if (p.startsWith("/en/")) { const rest = p.slice(3); const map = { "/wine-de-pasto": "/que-es-vino-de-pasto", "/paranormal": "/paranormal", "/bodegas-baron": "/bodegas-baron", "/notebook": "/blog" }; return map[rest] || "/"; } const map = { "/": "/en", "/que-es-vino-de-pasto": "/en/wine-de-pasto", "/paranormal": "/en/paranormal", "/bodegas-baron": "/en/bodegas-baron", "/blog": "/en/notebook" }; return map[p] || "/en"; } /* --- clean URL router with hash fallback for old links --- */ function normalisePath() { const hash = window.location.hash.replace(/^#/, ""); if (hash && hash.startsWith("/")) return hash; return window.location.pathname.replace(/\/$/, "") || "/"; } function useRoute() { const [route, setRoute] = React.useState(() => normalisePath()); React.useEffect(() => { const refresh = () => { setRoute(normalisePath()); window.scrollTo({ top: 0, behavior: "instant" }); }; window.addEventListener("popstate", refresh); window.addEventListener("hashchange", refresh); return () => { window.removeEventListener("popstate", refresh); window.removeEventListener("hashchange", refresh); }; }, []); return route; } function go(path) { window.history.pushState({}, "", path); window.dispatchEvent(new PopStateEvent("popstate")); } function Link({ to, children, className, style, onClick }) { return ( { if (onClick) onClick(e); if (!e.defaultPrevented && to && to.startsWith("/")) { e.preventDefault(); go(to); } }} > {children} ); } /* === Header === */ function Header({ route }) { const lang = currentLang(); const nav = lang === "en" ? NAV_EN : NAV; const en = lang === "en"; const active = (path) => { if (path === "/" || path === "/en") return route === path || (path === "/" && route === ""); return route === path || route.startsWith(path + "/"); }; const buyPath = en ? "/en/paranormal" : "/paranormal"; const langTarget = switchLangPath(); return (
VINODEPASTO · {SITE.domain}
{en ? "Buy Paranormal" : "Comprar Paranormal"} {en ? "ES" : "EN"} {en ? "ESPAÑOL" : "ENGLISH"}
{en ? "Sections" : "Secciones"}{en ? "Open" : "Abrir"}
{nav.map((n) => ( {n.label} ))} {en ? "Buy Paranormal" : "Comprar Paranormal"} {en ? "Español" : "English version"}
); } /* === Footer === */ function Footer() { const lang = currentLang(); const nav = lang === "en" ? NAV_EN : NAV; const en = lang === "en"; const buyPath = en ? "/en/paranormal" : "/paranormal"; return (
{en ? "Buy Paranormal" : "Comprar Paranormal"} {SITE.coupon}
); } /* === Reusable bits === */ function SectionNum({ n, children }) { return
{n}{children}
; } function CouponBox({ tone = "light" }) { const dark = tone === "dark"; const en = currentLang() === "en"; const [copied, setCopied] = React.useState(false); const copy = () => { navigator.clipboard && navigator.clipboard.writeText(SITE.coupon); setCopied(true); setTimeout(() => setCopied(false), 1600); }; return (
{en ? "Discount code" : "Código de descuento"}
{SITE.coupon}
{copied ? (en ? "Copied ✓" : "Copiado ✓") : (en ? "Copy →" : "Copiar →")}
); } function InlineCoupon({ tone = "dark" }) { const dark = tone === "dark"; const [copied, setCopied] = React.useState(false); const copy = (e) => { e.stopPropagation(); navigator.clipboard && navigator.clipboard.writeText(SITE.coupon); setCopied(true); setTimeout(() => setCopied(false), 1600); }; return (
{currentLang() === "en" ? "Code" : "Código"} {SITE.coupon} {copied ? "✓" : (currentLang() === "en" ? "Copy" : "Copiar")}
); } function ExternalBuyButton({ children = null, variant = "solid", small = false, showCoupon = true, href = SITE.buyUrl }) { const en = currentLang() === "en"; const label = children || (en ? "Buy from Bodegas Barón" : "Comprar en Bodegas Barón"); return (
{label} {showCoupon && }
); } /* AnimatedLabelBackground — video de etiqueta animada */ function AnimatedLabelBackground({ opacity = 0.55, position = "right" }) { return (
); } /* WineSpecCard — used in product page and home */ function WineSpec({ label, value }) { return (
{label}
{value}
); } /* Page wrapper with mount animation */ function Page({ children }) { return
{children}
; } Object.assign(window, { SITE, NAV, NAV_EN, currentLang, langPath, useRoute, go, Link, Header, Footer, SectionNum, CouponBox, InlineCoupon, ExternalBuyButton, AnimatedLabelBackground, WineSpec, Page, });