Skip to content

Commit c61e472

Browse files
committed
Routing Updated for Github Pages
1 parent 2afcaaa commit c61e472

File tree

11 files changed

+188
-109
lines changed

11 files changed

+188
-109
lines changed

src/App.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { Box, Container } from '@mantine/core';
88
import browserDetection from './components/utils/browserDetection';
99
import { preloadCriticalAssets } from './components/utils/assetPreloader';
1010
import { applyPerformanceOptimizations } from './components/utils/animationOptimizer';
11+
import { resolvePath } from './components/utils/paths';
12+
1113

1214
// Components
1315
import Header from './components/Header';
@@ -143,10 +145,10 @@ function App() {
143145
>
144146
<Routes>
145147
<Route path="/" element={<Home />} />
146-
<Route path="/hxndev.github.io/" element={<Home />} />
147-
<Route path="/hxndev.github.io/projects" element={<Projects />} />
148-
<Route path="/hxndev.github.io/about" element={<About />} />
149-
<Route path="/hxndev.github.io/contact" element={<Contact />} />
148+
<Route path={resolvePath('/')} element={<Home />} />
149+
<Route path={resolvePath('/projects')} element={<Projects />} />
150+
<Route path={resolvePath('/about')} element={<About />} />
151+
<Route path={resolvePath('/contact')} element={<Contact />} />
150152
</Routes>
151153
</Suspense>
152154
</PageTransition>

src/components/Header.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Link, useLocation } from 'react-router-dom';
33
import { IconSun, IconMoon } from '@tabler/icons-react';
44
import { useColorScheme } from '../theme/ThemeProvider';
55
import { useEffect, useRef } from 'react';
6+
import { resolvePath } from './utils/paths';
67

78
const Header = () => {
89
const location = useLocation();
@@ -50,7 +51,7 @@ const Header = () => {
5051
}}
5152
>
5253
<Group justify="space-between" align="center">
53-
<Link to="/hxndev.github.io/" style={{ textDecoration: 'none' }}>
54+
<Link to={resolvePath('/')} style={{ textDecoration: 'none' }}>
5455
<Title
5556
ref={titleRef}
5657
order={2}
@@ -69,10 +70,10 @@ const Header = () => {
6970

7071
<Group>
7172
{[
72-
{ path: '/hxndev.github.io/', label: 'Home' },
73-
{ path: '/hxndev.github.io/projects', label: 'Projects' },
74-
{ path: '/hxndev.github.io/about', label: 'About' },
75-
{ path: '/hxndev.github.io/contact', label: 'Contact' },
73+
{ path: resolvePath('/'), label: 'Home' },
74+
{ path: resolvePath('/projects'), label: 'Projects' },
75+
{ path: resolvePath('/about'), label: 'About' },
76+
{ path: resolvePath('/contact'), label: 'Contact' },
7677
].map((item, index) => (
7778
<Link key={item.path} to={item.path} style={{ textDecoration: 'none' }}>
7879
<Button
@@ -138,4 +139,4 @@ style.textContent = `
138139
`;
139140
document.head.appendChild(style);
140141

141-
export default Header;
142+
export default Header;

src/components/about/Timeline.jsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useColorScheme } from '../../theme/ThemeProvider';
77
/**
88
* Timeline item component with animation effects
99
*/
10-
const TimelineItem = ({ title, company, date, description, isActive = false }) => {
10+
const TimelineItem = ({ title, company, date, description, bullets = [], isActive = false }) => {
1111
const itemRef = useRef(null);
1212
const circleRef = useRef(null);
1313
const contentRef = useRef(null);
@@ -100,9 +100,28 @@ const TimelineItem = ({ title, company, date, description, isActive = false }) =
100100
<Text className="timeline-content" weight={500} size="md" mb="sm">
101101
{company}
102102
</Text>
103-
<Text className="timeline-content" mb="md">
104-
{description}
105-
</Text>
103+
104+
{/* Description - can be string or JSX */}
105+
<Box className="timeline-content" mb={bullets && bullets.length > 0 ? "sm" : "md"}>
106+
{typeof description === 'string' ? (
107+
<Text>{description}</Text>
108+
) : (
109+
description
110+
)}
111+
</Box>
112+
113+
{/* Bullets list - if provided */}
114+
{bullets && bullets.length > 0 && (
115+
<Box className="timeline-content" mb="md">
116+
<ul style={{ paddingLeft: "20px", margin: "0" }}>
117+
{bullets.map((bullet, index) => (
118+
<li key={index} style={{ marginBottom: "8px" }}>
119+
<Text component="span">{bullet}</Text>
120+
</li>
121+
))}
122+
</ul>
123+
</Box>
124+
)}
106125
</Box>
107126
</Box>
108127
);
@@ -123,8 +142,6 @@ const Timeline = ({ experiences = [] }) => {
123142
if (!timelineRef.current) return;
124143

125144
const timelineItems = timelineRef.current.querySelectorAll('.timeline-item');
126-
// Remove or comment out this line:
127-
// const timelineTop = timelineRef.current.getBoundingClientRect().top;
128145
const viewportHeight = window.innerHeight;
129146

130147
// Calculate which item should be active based on scroll position
@@ -197,6 +214,7 @@ const Timeline = ({ experiences = [] }) => {
197214
company={experience.company}
198215
date={experience.date}
199216
description={experience.description}
217+
bullets={experience.bullets}
200218
isActive={index === activeIndex}
201219
index={index}
202220
/>
@@ -207,4 +225,4 @@ const Timeline = ({ experiences = [] }) => {
207225
);
208226
};
209227

210-
export default Timeline;
228+
export default Timeline;

src/components/common/NavigationPulsar.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IconMenu2, IconHome, IconCode, IconUser, IconMail } from '@tabler/icons
44
import { useLocation, useNavigate } from 'react-router-dom';
55
import { useAnimationContext } from '../../context/AnimationContext';
66
import { gsap } from 'gsap';
7+
import { resolvePath } from '../utils/paths';
78

89
const NavigationPulsar = () => {
910
const [expanded, setExpanded] = useState(false);
@@ -14,10 +15,10 @@ const NavigationPulsar = () => {
1415
const { scrollVelocity, reducedMotion } = useAnimationContext();
1516

1617
const navigationItems = [
17-
{ path: '/hxndev.github.io/', label: 'Home', icon: <IconHome size={20} /> },
18-
{ path: '/hxndev.github.io/projects', label: 'Projects', icon: <IconCode size={20} /> },
19-
{ path: '/hxndev.github.io/about', label: 'About', icon: <IconUser size={20} /> },
20-
{ path: '/hxndev.github.io/contact', label: 'Contact', icon: <IconMail size={20} /> },
18+
{ path: resolvePath('/'), label: 'Home', icon: <IconHome size={20} /> },
19+
{ path: resolvePath('/projects'), label: 'Projects', icon: <IconCode size={20} /> },
20+
{ path: resolvePath('/about'), label: 'About', icon: <IconUser size={20} /> },
21+
{ path: resolvePath('/contact'), label: 'Contact', icon: <IconMail size={20} /> },
2122
];
2223

2324
// Handle navigation click

src/components/home/HeroSection.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Title, Text, Container, Button, Group, Grid, Box } from '@mantine/core'
33
import { IconDownload, IconBrandGithub, IconArrowRight } from '@tabler/icons-react';
44
import { gsap } from 'gsap';
55
import { useColorScheme } from '../../theme/ThemeProvider';
6+
import { resolveAssetPath } from '../utils/paths';
7+
68

79
const HeroSection = () => {
810
const containerRef = useRef(null);
@@ -198,7 +200,7 @@ const HeroSection = () => {
198200
<div className="profile-container" ref={imageRef}>
199201
<div className="profile-image-wrapper">
200202
<img
201-
src="/hxndev.github.io/images/profile.jpg"
203+
src={resolveAssetPath('images/profile.jpg')}
202204
alt="Hassan Shahzad"
203205
className="profile-image"
204206
/>

src/components/utils/assetPreloader.jsx

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* Utility for preloading assets to improve performance
33
*/
4+
import { resolveAssetPath } from '../utils/paths';
45

56
/**
67
* Preload an image
@@ -76,38 +77,44 @@ export const preloadFont = (fontFamily, src) => {
7677
* @returns {Array} Array of critical image URLs
7778
*/
7879
export const getCriticalImages = () => {
79-
return [
80+
// Define paths without prefix
81+
const imagePaths = [
8082
// Profile image
81-
'/hxndev.github.io/images/profile.jpg',
83+
'images/profile.jpg',
8284

8385
// Project images for featured projects
84-
'/hxndev.github.io/images/projects/3d-solar-system.jpg',
85-
'/hxndev.github.io/images/projects/ai-chess.jpg',
86-
'/hxndev.github.io/images/projects/brilliant-pro.jpg',
87-
'/hxndev.github.io/images/projects/event-management.jpg',
88-
'/hxndev.github.io/images/projects/exam-scheduler.jpg',
89-
'/hxndev.github.io/images/projects/face-mesh.jpg',
90-
'/hxndev.github.io/images/projects/graphical-password.jpg',
91-
'/hxndev.github.io/images/projects/hawkseye.jpg',
92-
'/hxndev.github.io/images/projects/image-to-sketch.jpg',
93-
'/hxndev.github.io/images/projects/insta-profile.jpg',
94-
'/hxndev.github.io/images/projects/job-fit.jpg',
95-
'/hxndev.github.io/images/projects/password-cracker.jpg',
96-
'/hxndev.github.io/images/projects/phy-app.jpg',
97-
'/hxndev.github.io/images/projects/portfolio.jpg',
98-
'/hxndev.github.io/images/projects/pose-detection.jpg',
99-
'/hxndev.github.io/images/projects/qr-code.jpg',
100-
'/hxndev.github.io/images/projects/ripple-effect.jpg',
101-
'/hxndev.github.io/images/projects/rock-paper-scissors.jpg',
102-
'/hxndev.github.io/images/projects/simple-translator.jpg',
103-
'/hxndev.github.io/images/projects/vehicle-buy-sell.jpg',
104-
'/hxndev.github.io/images/projects/video-to-gif.jpg',
105-
'/hxndev.github.io/images/projects/virtual-drag-and-drop.jpg',
106-
'/hxndev.github.io/images/projects/virtual-mouse.jpg',
86+
'images/projects/3d-solar-system.jpg',
87+
'images/projects/ai-chess.jpg',
88+
'images/projects/brilliant-pro.jpg',
89+
'images/projects/event-management.jpg',
90+
'images/projects/exam-scheduler.jpg',
91+
'images/projects/face-mesh.jpg',
92+
'images/projects/graphical-password.jpg',
93+
'images/projects/hawkseye.jpg',
94+
'images/projects/image-to-sketch.jpg',
95+
'images/projects/insta-profile.jpg',
96+
'images/projects/job-fit.jpg',
97+
'images/projects/password-cracker.jpg',
98+
'images/projects/phy-app.jpg',
99+
'images/projects/portfolio.jpg',
100+
'images/projects/pose-detection.jpg',
101+
'images/projects/qr-code.jpg',
102+
'images/projects/ripple-effect.jpg',
103+
'images/projects/rock-paper-scissors.jpg',
104+
'images/projects/simple-translator.jpg',
105+
'images/projects/vehicle-buy-sell.jpg',
106+
'images/projects/video-to-gif.jpg',
107+
'images/projects/virtual-drag-and-drop.jpg',
108+
'images/projects/virtual-mouse.jpg',
107109

108110
// Fallback images
109111
'https://placehold.co/600x400/9B00FF/FFFFFF?text=Image+Not+Found',
110112
];
113+
114+
// Resolve all paths
115+
return imagePaths.map(path =>
116+
path.startsWith('http') ? path : resolveAssetPath(path)
117+
);
111118
};
112119

113120
/**
@@ -127,4 +134,4 @@ export default {
127134
preloadFont,
128135
getCriticalImages,
129136
preloadCriticalAssets,
130-
};
137+
};

src/components/utils/imageUtils.jsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* Utility functions for handling image paths in portfolio
33
*/
4+
import { getBasePath as getBasePathUtil, resolveAssetPath } from '../../utils/paths';
45

56
/**
67
* Gets the correct image path based on environment and image path format
@@ -111,24 +112,11 @@ export const findWorkingImagePath = (imagePath, fallbackPath) => {
111112
* @returns {string} - The base path for assets
112113
*/
113114
export const getBasePath = () => {
114-
const { hostname, pathname } = window.location;
115-
116-
// GitHub Pages with custom domain
117-
if (!hostname.includes('github.io')) {
118-
return '/';
119-
}
120-
121-
// GitHub Pages with username.github.io/repo-name
122-
if (pathname.includes('/hxndev.github.io/')) {
123-
return '/hxndev.github.io/';
124-
}
125-
126-
// Local development
127-
return '/';
115+
return getBasePathUtil();
128116
};
129117

130118
export default {
131119
getImagePath,
132120
findWorkingImagePath,
133121
getBasePath,
134-
};
122+
};

src/components/utils/paths.jsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Central path utility for consistent path management throughout the app
3+
*/
4+
5+
// Base path configuration - edit this value to change path prefix globally
6+
const BASE_PATH = '/hxndev.github.io';
7+
8+
/**
9+
* Get the application base path
10+
* @returns {string} The base path for the application
11+
*/
12+
export const getBasePath = () => {
13+
return BASE_PATH;
14+
};
15+
16+
/**
17+
* Resolve a path using the application base path
18+
* @param {string} path - The path to resolve (should start with '/')
19+
* @returns {string} - The resolved path
20+
*/
21+
export const resolvePath = (path) => {
22+
// If already has the base path or is an external URL, return as is
23+
if (path.startsWith(BASE_PATH) || path.startsWith('http')) {
24+
return path;
25+
}
26+
27+
// Ensure path starts with slash
28+
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
29+
30+
// Combine base path with provided path
31+
return `${BASE_PATH}${normalizedPath}`;
32+
};
33+
34+
/**
35+
* Resolve an asset path
36+
* @param {string} path - The asset path
37+
* @returns {string} - The resolved asset path
38+
*/
39+
export const resolveAssetPath = (path) => {
40+
// Handle external URLs and absolute URLs differently
41+
if (path.startsWith('http')) {
42+
return path;
43+
}
44+
45+
// Remove leading slash if present
46+
const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
47+
48+
// Combine base path with asset path
49+
return `${BASE_PATH}/${normalizedPath}`;
50+
};

0 commit comments

Comments
 (0)