Skip to content

Commit 467c205

Browse files
committed
fix(docs): add GITHUB_REPOSITORY fallback to build-docs.js
build-docs.js was defaulting to localhost:4321 when SITE_URL wasn't set, bypassing the GITHUB_REPOSITORY fallback in site-url.js. This caused CSS paths to be missing the /BMAD-METHOD/ base path on fork deployments. Now both files have the same URL resolution logic: SITE_URL -> GITHUB_REPOSITORY -> localhost:4321
1 parent 9ffbc06 commit 467c205

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

tools/build-docs.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ const archiver = require('archiver');
2121
const PROJECT_ROOT = path.dirname(__dirname);
2222
const BUILD_DIR = path.join(PROJECT_ROOT, 'build');
2323

24-
// For local builds, use localhost. Production URL set via SITE_URL env var in CI.
25-
const SITE_URL = process.env.SITE_URL || 'http://localhost:4321';
24+
// Same logic as website/src/lib/site-url.js - duplicated to avoid CJS/ESM complexity
25+
function getSiteUrl() {
26+
if (process.env.SITE_URL) return process.env.SITE_URL;
27+
if (process.env.GITHUB_REPOSITORY) {
28+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
29+
return `https://${owner}.github.io/${repo}`;
30+
}
31+
return 'http://localhost:4321';
32+
}
33+
const SITE_URL = getSiteUrl();
2634
const REPO_URL = 'https://github.com/bmad-code-org/BMAD-METHOD';
2735

2836
const LLM_MAX_CHARS = 600_000;

website/src/lib/site-url.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Resolve the site's base URL using cascading environment defaults.
33
*
44
* Preference order: use SITE_URL if set; otherwise derive a GitHub Pages URL from GITHUB_REPOSITORY; otherwise use the local development URL.
5-
* @returns {string} The resolved site URL (SITE_URL override, or `https://{owner}.github.io/{repo}`, or `http://localhost:3000`).
5+
* @returns {string} The resolved site URL (SITE_URL override, or `https://{owner}.github.io/{repo}`, or `http://localhost:4321`).
66
*/
77
export function getSiteUrl() {
88
// Explicit override (works in both local and GitHub Actions)
@@ -20,6 +20,6 @@ export function getSiteUrl() {
2020
return `https://${owner}.github.io/${repo}`;
2121
}
2222

23-
// Local development: use dev server
24-
return 'http://localhost:3000';
23+
// Local development: use Astro dev server
24+
return 'http://localhost:4321';
2525
}

0 commit comments

Comments
 (0)