Skip to content

Commit aa6a44a

Browse files
committed
Fix GitHub Pages deployment: correct basePath and assetPrefix configuration for CSS and assets loading
1 parent 01de58a commit aa6a44a

7 files changed

Lines changed: 18 additions & 6 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
run: npm ci
3333

3434
- name: Build project
35+
env:
36+
GITHUB_ACTIONS: true
3537
run: npm run export
3638

3739
- name: Add .nojekyll file

next.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const nextConfig: NextConfig = {
44
// Configuración para GitHub Pages
55
output: 'export',
66
trailingSlash: true,
7-
basePath: process.env.GITHUB_ACTIONS ? '/dataplug_web' : '',
8-
assetPrefix: process.env.GITHUB_ACTIONS ? '/dataplug_web/' : '',
7+
basePath: process.env.NODE_ENV === 'production' ? '/dataplug-web' : '',
8+
assetPrefix: process.env.NODE_ENV === 'production' ? '/dataplug-web/' : '',
99

1010
turbopack: {
1111
rules: {

src/app/components/Footer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React from 'react';
44
import { Layout, Row, Col, Typography, Space, Divider, List } from 'antd';
55
import { GithubOutlined } from '@ant-design/icons';
66
import Image from 'next/image';
7+
import { getAssetPath } from '../utils';
78

89
const { Footer: AntFooter } = Layout;
910
const { Title, Paragraph } = Typography;
@@ -24,7 +25,7 @@ export default function Footer({ showPyRun = true }: FooterProps) {
2425
<Col xs={24} md={6}>
2526
<div style={{ display: 'flex', alignItems: 'center', gap: '12px', marginBottom: 16 }}>
2627
<Image
27-
src="/logo.svg"
28+
src={getAssetPath("/logo.svg")}
2829
alt="DataPlug Logo"
2930
width={28}
3031
height={28}

src/app/components/Header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Layout, Row, Col, Typography, Space, Button } from 'antd';
55
import { BookOutlined } from '@ant-design/icons';
66
import Link from 'next/link';
77
import Image from 'next/image';
8+
import { getAssetPath } from '../utils';
89

910
const { Header: AntHeader } = Layout;
1011
const { Title } = Typography;
@@ -29,7 +30,7 @@ export default function Header({ showPyRun = true }: HeaderProps) {
2930
<Col>
3031
<div style={{ display: 'flex', alignItems: 'center', gap: '16px' }}>
3132
<Image
32-
src="/logo.svg"
33+
src={getAssetPath("/logo.svg")}
3334
alt="DataPlug Logo"
3435
width={90}
3536
height={90}

src/app/components/sections/HeroSection.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Typography, Space, Button } from 'antd';
55
import { RocketOutlined, PlayCircleOutlined, DatabaseOutlined, CloudOutlined } from '@ant-design/icons';
66
import Link from 'next/link';
77
import Image from 'next/image';
8+
import { getAssetPath } from '../../utils';
89

910
const { Title, Paragraph, Text } = Typography;
1011

@@ -95,7 +96,7 @@ export default function HeroSection() {
9596
filter: 'drop-shadow(0 0 30px rgba(100, 200, 255, 0.3))'
9697
}}>
9798
<Image
98-
src="/logo.svg"
99+
src={getAssetPath("/logo.svg")}
99100
alt="DataPlug Logo"
100101
width={200}
101102
height={200}

src/app/docs/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
import Link from 'next/link';
4545
import Image from 'next/image';
4646
import { dataCockpitInstallation, dataCockpitInstallationWithExtras } from '../data/dataCockpit';
47+
import { getAssetPath } from '../utils';
4748
import { pyrunUrl } from '../data/pyrun';
4849
import { formatExamples, allExamplesUrl } from '../data/examples';
4950

@@ -296,7 +297,7 @@ results = bag.map(lambda slice: len(slice.get().split('>')) - 1).compute()`;
296297
<Link href="/" style={{ textDecoration: 'none' }}>
297298
<div style={{ display: 'flex', alignItems: 'center', gap: '12px', cursor: 'pointer' }}>
298299
<Image
299-
src="/logo.svg"
300+
src={getAssetPath("/logo.svg")}
300301
alt="DataPlug Logo"
301302
width={28}
302303
height={28}

src/app/utils/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ export const formatDuration = (seconds: number): string => {
2626
const hours = Math.floor(seconds / 3600);
2727
const minutes = Math.floor((seconds % 3600) / 60);
2828
return `${hours}h ${minutes}m`;
29+
};
30+
31+
// Utility function to handle asset paths for GitHub Pages
32+
export const getAssetPath = (path: string): string => {
33+
const basePath = process.env.NODE_ENV === 'production' ? '/dataplug-web' : '';
34+
return `${basePath}${path}`;
2935
};

0 commit comments

Comments
 (0)