Skip to content

Commit

Permalink
Fix path githubPages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariovido committed Oct 15, 2023
1 parent 705ef28 commit 339788c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 28 deletions.
20 changes: 7 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import { Suspense, lazy } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { CONFIG } from './config/config';
const Portfolio = lazy(() => import('./pages/Portfolio'));
const Resume = lazy(() => import('./pages/Resume'));
const NotFound = lazy(() => import('./pages/NotFound'));
Expand All @@ -9,20 +10,13 @@ import './App.scss';

const router = createBrowserRouter([
{
path: '/',
element: <Portfolio />,
// children: [
// {index: true, element:}
// ],
},
{
path: '/resume',
element: <Resume />,
},
{
path: '*',
element: <NotFound />,
path: `/${CONFIG.VITE_REACT_APP_BASE_URL}`,
children: [
{ index: true, element: <Portfolio /> },
{ path: 'resume', element: <Resume /> },
],
},
{ path: '*', element: <NotFound /> },
]);

const queryClient = new QueryClient();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Portfolio/Experiences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Experiences() {
<LinkIcon
isAnchor={false}
linkProps={{
href: '/resume',
href: 'resume',
whileHover: 'hover',
animate: 'rest',
variants: ResumeVariants,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Portfolio/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Header() {
return (
<header className="header">
<div>
<Link to="/" onClick={handleOnClick}>
<Link to={`${CONFIG.VITE_REACT_APP_BASE_URL}`} onClick={handleOnClick}>
<h1 className="name">{headerInfo.name}</h1>
</Link>
<h2 className="role">{headerInfo.role}</h2>
Expand Down
3 changes: 2 additions & 1 deletion src/components/shared/Navigation/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Link, useNavigate } from 'react-router-dom';
import { NavBarProps } from '../../../models/interfaces/shared/Navigation/NavBarProps';
import { useCallback, useEffect, useState } from 'react';
import { CONFIG } from '../../../config/config';

import './styles/NavBar.scss';

Expand Down Expand Up @@ -68,7 +69,7 @@ function NavBar(props: NavBarProps) {

changeActiveBar(`#${location[1]}`);

navigate(`/#${location[1]}`);
navigate(`${CONFIG.VITE_REACT_APP_BASE_URL}#${location[1]}`);
};

return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/shared/UI/Icons/LinkIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { motion } from 'framer-motion';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { LinkIconProps } from '../../../../models/interfaces/shared/UI/Icons/LinkIconProps';
import { Link } from 'react-router-dom';
import { CONFIG } from '../../../../config/config';

import './styles/LinkIcon.scss';

Expand Down Expand Up @@ -34,7 +35,7 @@ function LinkIcon(props: LinkIconProps) {
) : (
<MotionLink
className={`link-icon ${linkProps.className}`}
to={linkProps.href}
to={`${CONFIG.VITE_REACT_APP_BASE_URL}${linkProps.href}`}
whileHover={linkProps.whileHover}
animate={linkProps.animate}
onHoverStart={linkProps.onHoverStart}
Expand Down
1 change: 1 addition & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export const CONFIG = {
VITE_REACT_APP_USE_SERVER:
import.meta.env.VITE_REACT_APP_USE_SERVER === 'true',
VITE_REACT_APP_WEB_TITLE: import.meta.env.VITE_REACT_APP_WEB_TITLE,
VITE_REACT_APP_BASE_URL: import.meta.env.VITE_REACT_APP_BASE_URL,
};
3 changes: 2 additions & 1 deletion src/pages/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Button from '../components/shared/UI/Buttons/Button';
import { ButtonVariants } from '../utils/variants/variants';
import { faArrowLeft } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { CONFIG } from '../config/config';

import './styles/NotFound.scss';

Expand All @@ -13,7 +14,7 @@ function NotFound() {
const handleOnClick = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();

navigate('/');
navigate(`${CONFIG.VITE_REACT_APP_BASE_URL}`);
};
return (
<>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Resume.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { faArrowLeft } from '@fortawesome/free-solid-svg-icons';
import { ButtonVariants } from '../utils/variants/variants';
import { ResumeLocation } from '../models/interfaces/pages/ResumeLocation';
import Cursor from '../components/shared/Common/Cursor';
import { CONFIG } from '../config/config';

import './styles/Resume.scss';

Expand All @@ -23,7 +24,7 @@ function Resume() {

if (state?.prevPath) {
navigate(-1);
} else navigate('/');
} else navigate(`${CONFIG.VITE_REACT_APP_BASE_URL}`);
};

return (
Expand Down
22 changes: 13 additions & 9 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/// <reference types="vitest" />
/// <reference types="vite/client" />

import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react-swc';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./test/setupTests.ts'],
},
base: '/portfolio-frontend/',
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');

return {
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./test/setupTests.ts'],
},
base: env.VITE_REACT_APP_BASE_URL,
};
});

0 comments on commit 339788c

Please sign in to comment.