From b2c047f0b7894487645bb8c53ef88bc8b491377d Mon Sep 17 00:00:00 2001 From: Alex Verkhovsky Date: Thu, 5 Feb 2026 19:45:58 -0700 Subject: [PATCH] fix: unify site URL resolution in build-docs.js build-docs.js had its own hardcoded fallback URL (bmad-code-org.github.io) instead of using the shared getSiteUrl() function, causing URL mismatches between robots.txt, llms.txt, and sitemaps. Now all components resolve the site URL through the same function. Renamed site-url.js to .mjs to avoid Node ESM detection warnings. --- tools/build-docs.js | 8 +++++++- website/astro.config.mjs | 2 +- website/src/components/Banner.astro | 2 +- website/src/lib/{site-url.js => site-url.mjs} | 0 4 files changed, 9 insertions(+), 3 deletions(-) rename website/src/lib/{site-url.js => site-url.mjs} (100%) diff --git a/tools/build-docs.js b/tools/build-docs.js index dfb2c0a8e..878eeee8f 100644 --- a/tools/build-docs.js +++ b/tools/build-docs.js @@ -21,7 +21,7 @@ const archiver = require('archiver'); const PROJECT_ROOT = path.dirname(__dirname); const BUILD_DIR = path.join(PROJECT_ROOT, 'build'); -const SITE_URL = process.env.SITE_URL || 'https://bmad-code-org.github.io/BMAD-METHOD'; +let SITE_URL; // Resolved in main() via shared getSiteUrl() const REPO_URL = 'https://github.com/bmad-code-org/BMAD-METHOD'; // DO NOT CHANGE THESE VALUES! @@ -53,6 +53,12 @@ const LLM_EXCLUDE_PATTERNS = [ */ async function main() { + // Resolve site URL using the same function as Astro config + const { pathToFileURL } = require('node:url'); + const siteUrlModule = path.join(PROJECT_ROOT, 'website/src/lib/site-url.mjs'); + const { getSiteUrl } = await import(pathToFileURL(siteUrlModule).href); + SITE_URL = getSiteUrl(); + console.log(); printBanner('BMAD Documentation Build Pipeline'); console.log(); diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 23a3179c4..d59de430a 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -4,7 +4,7 @@ import starlight from '@astrojs/starlight'; import sitemap from '@astrojs/sitemap'; import rehypeMarkdownLinks from './src/rehype-markdown-links.js'; import rehypeBasePaths from './src/rehype-base-paths.js'; -import { getSiteUrl } from './src/lib/site-url.js'; +import { getSiteUrl } from './src/lib/site-url.mjs'; const siteUrl = getSiteUrl(); const urlParts = new URL(siteUrl); diff --git a/website/src/components/Banner.astro b/website/src/components/Banner.astro index f1e460705..218a017ee 100644 --- a/website/src/components/Banner.astro +++ b/website/src/components/Banner.astro @@ -1,5 +1,5 @@ --- -import { getSiteUrl } from '../lib/site-url.js'; +import { getSiteUrl } from '../lib/site-url.mjs'; const SITE_URL = getSiteUrl(); const fullDocsUrl = `${SITE_URL}/llms-full.txt`; diff --git a/website/src/lib/site-url.js b/website/src/lib/site-url.mjs similarity index 100% rename from website/src/lib/site-url.js rename to website/src/lib/site-url.mjs