Skip to content

Commit 0503b60

Browse files
fix: use BASE_PATH env var for configurable base path in production builds
1 parent 13ec22c commit 0503b60

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: Build website
6868
run: ap build
6969
env:
70-
NODE_ENV: production
70+
BASE_PATH: /afterpython
7171

7272
- name: Upload artifact
7373
uses: actions/upload-pages-artifact@v3

afterpython/_website/svelte.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ const config = {
1616
precompress: false,
1717
strict: true,
1818
}),
19+
// GitHub Pages serves sites from a subdirectory (e.g., username.github.io/repo-name/)
20+
// Set base path via BASE_PATH env var so all routes and assets are correctly prefixed
21+
// Without this, routes like /doc would resolve to username.github.io/doc instead of username.github.io/afterpython/doc
1922
paths: {
20-
base: process.env.NODE_ENV === 'production' ? '/afterpython' : '',
23+
base: process.env.BASE_PATH || '',
2124
},
2225
alias: {
2326
// '@': 'src/',

afterpython/templates/deploy-workflow-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: Build website
6868
run: ap build
6969
env:
70-
NODE_ENV: production
70+
BASE_PATH: /afterpython
7171

7272
- name: Upload artifact
7373
uses: actions/upload-pages-artifact@v3

0 commit comments

Comments
 (0)