Skip to content

Commit 36bda75

Browse files
committed
Github Workflows Added
1 parent b84b8a6 commit 36bda75

File tree

4 files changed

+68
-30
lines changed

4 files changed

+68
-30
lines changed

.github/workflows/deploy.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 19
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Build
31+
run: npm run build
32+
33+
- name: Setup Pages
34+
uses: actions/configure-pages@v3
35+
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v2
38+
with:
39+
path: './dist'
40+
41+
deploy:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
runs-on: ubuntu-latest
46+
needs: build
47+
steps:
48+
- name: Deploy to GitHub Pages
49+
id: deployment
50+
uses: actions/deploy-pages@v2

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" href="/hxndev.github.io/favicon.ico" />
5+
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Hassan Shahzad | Portfolio</title>
88
</head>

src/components/utils/paths.jsx

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,38 @@
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';
1+
// Detect if we're in production or development
2+
const isProd = import.meta.env.PROD;
73

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-
};
4+
// Base path should be empty for username.github.io repos
5+
export const BASE_PATH = '';
156

167
/**
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
8+
* Resolves a path based on environment
209
*/
21-
export const resolvePath = (path) => {
10+
export function resolvePath(path) {
2211
// If already has the base path or is an external URL, return as is
23-
if (path.startsWith(BASE_PATH) || path.startsWith('http')) {
12+
if (path.startsWith('http')) {
2413
return path;
2514
}
2615

2716
// Ensure path starts with slash
2817
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
2918

30-
// Combine base path with provided path
19+
// In production (GitHub Pages), use the base path
20+
// In development, use paths as is
3121
return `${BASE_PATH}${normalizedPath}`;
32-
};
22+
}
3323

3424
/**
35-
* Resolve an asset path
36-
* @param {string} path - The asset path
37-
* @returns {string} - The resolved asset path
25+
* Resolves an asset path
3826
*/
39-
export const resolveAssetPath = (path) => {
40-
// Handle external URLs and absolute URLs differently
27+
export function resolveAssetPath(path) {
28+
// Handle external URLs
4129
if (path.startsWith('http')) {
4230
return path;
4331
}
4432

4533
// Remove leading slash if present
4634
const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
4735

48-
// Combine base path with asset path
36+
// In production, assets are at the root
4937
return `${BASE_PATH}/${normalizedPath}`;
50-
};
38+
}

vite.config.js

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

8-
// Match the base path used in your path utility
9-
base: '/hxndev.github.io/',
8+
// For username.github.io repos, the base URL should be '/' in production
9+
base: '/',
1010

1111
build: {
1212
outDir: 'dist',

0 commit comments

Comments
 (0)