fix(path): improper redirects in subpath domain sites

This commit is contained in:
saberzero1
2026-04-22 18:25:05 +02:00
parent ff19a3bf38
commit b3082c32dc
4 changed files with 22 additions and 9 deletions
+7 -2
View File
@@ -78,10 +78,15 @@ async function emitPage(
) {
const cfg = ctx.cfg.configuration
// For the 404 page, use an absolute base path so assets resolve correctly
// when the hosting provider serves 404.html from any URL depth
// when the hosting provider serves 404.html from any URL depth.
// During local dev (--serve), the dev server strips baseDir itself and
// serves files from root, so the 404 page must use "/" to avoid requesting
// assets under a path prefix that the dev server doesn't serve.
const baseDir =
slug === "404"
? (new URL(`https://${cfg.baseUrl ?? "example.com"}`).pathname as FullSlug)
? ((ctx.argv.serve
? "/"
: new URL(`https://${cfg.baseUrl ?? "example.com"}`).pathname) as FullSlug)
: pathToRoot(slug)
const externalResources = pageResources(baseDir, resources)
const componentData: QuartzComponentProps = {