fix: use correct baseurl in serve mode

This commit is contained in:
saberzero1
2026-05-26 12:56:18 +02:00
parent 2862ec7303
commit ad685b8d4e
2 changed files with 8 additions and 4 deletions
+6 -1
View File
@@ -337,7 +337,12 @@ export function renderPage(
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
const direction = i18n(cfg.locale).direction ?? "ltr"
const basePath = cfg.baseUrl ? new URL(`https://${cfg.baseUrl}`).pathname.replace(/\/$/, "") : ""
// During local dev (--serve), the dev server serves from root without the
// baseUrl subpath, so basePath must be empty to avoid broken links.
const basePath =
componentData.ctx.argv.serve || !cfg.baseUrl
? ""
: new URL(`https://${cfg.baseUrl}`).pathname.replace(/\/$/, "")
const doc = (
<html lang={lang} dir={direction}>
<Head {...componentData} />