fix: use absolute asset paths for 404 page so it works in subdirectories

This commit is contained in:
saberzero1 2026-02-28 14:44:14 +01:00
parent 8dcc1522d9
commit 02d0f23030
No known key found for this signature in database

View File

@ -76,7 +76,13 @@ async function emitPage(
resources: StaticResources, resources: StaticResources,
) { ) {
const cfg = ctx.cfg.configuration const cfg = ctx.cfg.configuration
const externalResources = pageResources(pathToRoot(slug), resources) // For the 404 page, use an absolute base path so assets resolve correctly
// when the hosting provider serves 404.html from any URL depth
const baseDir =
slug === "404"
? (new URL(`https://${cfg.baseUrl ?? "example.com"}`).pathname as FullSlug)
: pathToRoot(slug)
const externalResources = pageResources(baseDir, resources)
const componentData: QuartzComponentProps = { const componentData: QuartzComponentProps = {
ctx, ctx,
fileData, fileData,