diff --git a/scripts/post-build.js b/scripts/post-build.js index ef90434..fe867a2 100644 --- a/scripts/post-build.js +++ b/scripts/post-build.js @@ -50,6 +50,9 @@ if (process.env.NODE_ENV === 'production' && process.env.DEPLOY_TARGET === 'gith // Move logos directory to web-novit/logos moveDirectory('logos', 'web-novit/logos', '/logos/ → /web-novit/logos/'); + // Move video directory to web-novit/video + moveDirectory('video', 'web-novit/video', '/video/ → /web-novit/video/'); + // Keep root files at root for GitHub Pages console.log('✅ Root files maintained for GitHub Pages compatibility'); diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 068bd3f..2c86c78 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -1,7 +1,6 @@ 'use client'; import { useState, useEffect } from 'react'; -import Link from 'next/link'; import Image from 'next/image'; import { Menu, X } from 'lucide-react'; import { useLocale } from 'next-intl'; @@ -91,6 +90,7 @@ export default function Header({ locale: localeParam, navigationContent }: Heade {item.label} @@ -151,6 +151,7 @@ export default function Header({ locale: localeParam, navigationContent }: Heade setIsMobileMenuOpen(false)} > @@ -196,6 +197,7 @@ export default function Header({ locale: localeParam, navigationContent }: Heade
diff --git a/src/components/ui/HomeLink.tsx b/src/components/ui/HomeLink.tsx index 7d213ce..5c4ab8c 100644 --- a/src/components/ui/HomeLink.tsx +++ b/src/components/ui/HomeLink.tsx @@ -10,16 +10,21 @@ interface HomeLinkProps { children: ReactNode; className?: string; onClick?: () => void; + href?: string; // Allow passing pre-computed href } export default function HomeLink({ locale, children, className = '', - onClick + onClick, + href: providedHref }: HomeLinkProps) { const pathname = usePathname(); + // Use provided href or generate default one + const homeHref = providedHref || getAssetPath(`/${locale}/#home`); + const handleClick = (e: React.MouseEvent) => { // Verificar si ya estamos en la página home const isHomePage = pathname === `/${locale}` || pathname === `/${locale}/`; @@ -59,7 +64,7 @@ export default function HomeLink({ return ( diff --git a/src/config/constants.ts b/src/config/constants.ts index b2f97eb..d3d2f2d 100644 --- a/src/config/constants.ts +++ b/src/config/constants.ts @@ -7,6 +7,19 @@ const isGitHubPagesBuild = process.env.DEPLOY_TARGET === 'github-pages'; +/** + * Detect if we're currently running on GitHub Pages (client-side detection) + */ +function isOnGitHubPages(): boolean { + if (typeof window === 'undefined') { + // Server-side: use build-time environment variable + return isGitHubPagesBuild; + } + + // Client-side: detect GitHub Pages by checking if URL contains /web-novit + return window.location.pathname.startsWith('/web-novit'); +} + /** * Get the correct asset path with base path for deployment */ @@ -19,8 +32,19 @@ export function getAssetPath(path: string): string { return normalizedPath; } - // Next.js maneja automáticamente el basePath cuando está configurado - // Solo necesitamos devolver el path normalizado y Next.js se encarga del resto + // Durante build time para GitHub Pages, Next.js maneja automáticamente el basePath + // En el cliente, si ya estamos en GitHub Pages, no necesitamos agregar basePath + // porque Next.js ya lo ha aplicado a las rutas + const isGitHub = isOnGitHubPages(); + + // Si estamos en build de GitHub Pages (server-side) o ya estamos en GitHub Pages (client-side), + // no agregamos basePath porque Next.js ya lo maneja + if (isGitHub) { + return normalizedPath; + } + + // Solo para desarrollo local u otros entornos que no sean GitHub Pages + return normalizedPath; }