Skip to content

Commit 58b3c01

Browse files
committed
Fix (Featured Projects routing issue)
1 parent 9fee779 commit 58b3c01

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

src/App.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,27 @@ function App() {
143143
}
144144
>
145145
<Routes>
146+
{/* Base routes */}
146147
<Route path="/" element={<Home />} />
148+
<Route path="/projects" element={<Projects />} />
149+
<Route path="/about" element={<About />} />
150+
<Route path="/contact" element={<Contact />} />
151+
152+
{/* Support for both base routes and resolved paths */}
147153
<Route path={resolvePath('/')} element={<Home />} />
148154
<Route path={resolvePath('/projects')} element={<Projects />} />
149155
<Route path={resolvePath('/about')} element={<About />} />
150156
<Route path={resolvePath('/contact')} element={<Contact />} />
151157

152158
{/* Redirect to JobFit application */}
159+
<Route
160+
path="/JobFit"
161+
element={<Navigate to="https://hxndev.github.io/JobFit/" replace />}
162+
/>
163+
<Route
164+
path="/JobFit/*"
165+
element={<Navigate to="https://hxndev.github.io/JobFit/" replace />}
166+
/>
153167
<Route
154168
path={resolvePath('/JobFit')}
155169
element={<Navigate to="https://hxndev.github.io/JobFit/" replace />}
@@ -158,6 +172,9 @@ function App() {
158172
path={resolvePath('/JobFit/*')}
159173
element={<Navigate to="https://hxndev.github.io/JobFit/" replace />}
160174
/>
175+
176+
{/* Catch-all route */}
177+
<Route path="*" element={<Navigate to="/" replace />} />
161178
</Routes>
162179
</Suspense>
163180
</PageTransition>

src/components/projects/EnhancedProjectCard.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const EnhancedProjectCard = ({
6060
const handleCardClick = e => {
6161
e.preventDefault();
6262
if (onViewDetails && projectId) {
63-
onViewDetails(projectId);
63+
onViewDetails(projectId, 'page');
6464
}
6565
};
6666

@@ -69,7 +69,7 @@ const EnhancedProjectCard = ({
6969
e.preventDefault();
7070
e.stopPropagation();
7171
if (onViewDetails && projectId) {
72-
onViewDetails(projectId);
72+
onViewDetails(projectId, 'page');
7373
}
7474
};
7575

src/components/utils/paths.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Detect if we're in production or development
22
const _isProd = import.meta.env.PROD;
33

4-
// Base path should be empty for username.github.io repos
4+
// For GitHub Pages repository project sites, this should be the repo name
5+
// For username.github.io personal sites, this should be empty
56
export const BASE_PATH = '';
67

78
/**
89
* Resolves a path based on environment
10+
* This handles routing correctly for GitHub Pages
911
*/
1012
export function resolvePath(path) {
1113
// If already has the base path or is an external URL, return as is

src/pages/Home.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22
import { Title, Text, Container, Button, Grid, Loader, Box, SimpleGrid } from '@mantine/core';
3+
import { useNavigate } from 'react-router-dom';
4+
import { resolvePath } from '../components/utils/paths';
35
import HeroSection from '../components/home/HeroSection';
46
import EnhancedProjectCard from '../components/projects/EnhancedProjectCard';
57
import SponsorshipSection from '../components/SponsorshipSection';
@@ -8,6 +10,7 @@ import AnimatedSection from '../components/common/AnimatedSection';
810
import { useColorScheme } from '../theme/ThemeProvider';
911

1012
const Home = () => {
13+
const navigate = useNavigate();
1114
const {
1215
projects: allProjects,
1316
loading: projectsLoading,
@@ -24,7 +27,11 @@ const Home = () => {
2427
}, [allProjects]);
2528

2629
const handleViewDetails = projectId => {
27-
window.location.href = `/projects?project=${projectId}`;
30+
// Pass the projectId and action to our handler
31+
navigate({
32+
pathname: resolvePath('/projects'),
33+
search: `?project=${projectId}`,
34+
});
2835
};
2936

3037
return (

vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'path';
55
export default defineConfig({
66
plugins: [react()],
77

8-
// For username.github.io repos, the base URL should be '/' in production
8+
// For username.github.io personal sites, the base URL should be '/'
99
base: '/',
1010

1111
build: {

0 commit comments

Comments
 (0)