Skip to content

Commit b2f804e

Browse files
committed
refactor: consolidate Next.js config and improve environment variable handling
- Remove redundant next.config.js in favor of next.config.ts - Move all configurations to TypeScript file - Replace hardcoded basePath with environment variable - Update GitHub Actions workflow to use NEXT_PUBLIC_BASE_PATH - Update README with environment setup instructions - Add local .env setup steps - Add GitHub repository secrets configuration - Improve deployment documentation
1 parent b4e26cf commit b2f804e

4 files changed

Lines changed: 24 additions & 28 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ permissions:
1010
jobs:
1111
build-and-deploy:
1212
runs-on: ubuntu-latest
13+
env:
14+
NEXT_PUBLIC_BASE_PATH: attarchi.github.io
1315
steps:
1416
- name: Checkout
1517
uses: actions/checkout@v4

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ cd attarchi.github.io
3737
yarn install
3838
```
3939

40-
3. Run the development server:
40+
3. Set up environment variables:
41+
Create a `.env` file in the root directory with:
42+
```
43+
NEXT_PUBLIC_BASE_PATH=your-username.github.io
44+
```
45+
46+
4. Run the development server:
4147
```bash
4248
yarn dev
4349
```
@@ -82,20 +88,15 @@ The site is automatically deployed to GitHub Pages using GitHub Actions. Each pu
8288
- Navigate to "Pages" under "Code and automation"
8389
- Set the source to "GitHub Actions"
8490

85-
2. **Next.js Configuration**
86-
Add the following to your `next.config.js`:
87-
```js
88-
/** @type {import('next').NextConfig} */
89-
const nextConfig = {
90-
output: 'export',
91-
basePath: '/<youname>.github.io',
92-
images: {
93-
unoptimized: true,
94-
},
95-
}
96-
97-
module.exports = nextConfig
98-
```
91+
2. **Environment Setup**
92+
- Create a `.env` file with your GitHub Pages base path (<yourname>.github.io)
93+
- For GitHub Actions, add the environment variable to your GitHub repository:
94+
1. Go to your repository settings
95+
2. Navigate to "Secrets and variables" → "Actions"
96+
3. Click "New repository secret"
97+
4. Name: `NEXT_PUBLIC_BASE_PATH`
98+
5. Value: `<yourname>.github.io`
99+
6. Click "Add secret"
99100

100101
3. **Custom Domain (Optional)**
101102
- Add your custom domain in repository settings

next.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
output: 'export',
4-
images: {
5-
unoptimized: true,
6-
},
7-
basePath: process.env.NODE_ENV === 'production' ? '/attarchi.github.io' : '',
8-
trailingSlash: true,
3+
output: 'export',
4+
images: {
5+
unoptimized: true,
6+
},
7+
basePath: process.env.NEXT_PUBLIC_BASE_PATH || '',
8+
trailingSlash: true,
99
}
1010

1111
module.exports = nextConfig

next.config.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)