Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/post-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
4 changes: 3 additions & 1 deletion src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -91,6 +90,7 @@ export default function Header({ locale: localeParam, navigationContent }: Heade
<HomeLink
key={item.href}
locale={locale}
href={item.href}
className="text-white/90 hover:text-white font-medium transition-colors duration-200 relative group"
>
{item.label}
Expand Down Expand Up @@ -151,6 +151,7 @@ export default function Header({ locale: localeParam, navigationContent }: Heade
<HomeLink
key={item.href}
locale={locale}
href={item.href}
className="block text-white/90 hover:text-white font-medium py-2 transition-colors"
onClick={() => setIsMobileMenuOpen(false)}
>
Expand Down Expand Up @@ -196,6 +197,7 @@ export default function Header({ locale: localeParam, navigationContent }: Heade
<HomeLink
key={item.href}
locale={locale}
href={item.href}
className="flex flex-col items-center p-2 text-xs font-medium text-white/80 hover:text-white transition-colors"
>
<div className="w-6 h-6 mb-1 flex items-center justify-center">
Expand Down
9 changes: 7 additions & 2 deletions src/components/ui/HomeLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}/`;
Expand Down Expand Up @@ -59,7 +64,7 @@ export default function HomeLink({

return (
<Link
href={getAssetPath(`/${locale}/#home`)}
href={homeHref}
className={className}
onClick={handleClick}
>
Expand Down
28 changes: 26 additions & 2 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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;
}

Expand Down
Loading