From 4ae96eb52c906d070df7623e2b5ae1cee848d043 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Wed, 18 Mar 2026 11:50:43 +0100 Subject: [PATCH] fix: resolve links correctly on subdirectory deployments Use resolveBasePath() from @quartz-community/utils/path to prepend the base path when navigating via SPA routing. Fixes links resolving to the domain root instead of the subdirectory. --- package-lock.json | 37 +++++++++++++++++++++++++++++++++++++ package.json | 1 + src/index.ts | 3 ++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 03ef805..3bc8d8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@quartz-community/types": "github:quartz-community/types", + "@quartz-community/utils": "github:quartz-community/utils", "tsup": "^8.5.0", "typescript": "^5.9.3" }, @@ -481,6 +482,31 @@ } } }, + "node_modules/@quartz-community/utils": { + "version": "0.1.0", + "resolved": "git+ssh://git@github.com/quartz-community/utils.git#81189f697c813648b318f4d8ae681723b4453a76", + "license": "MIT", + "dependencies": { + "@quartz-community/types": "github:quartz-community/types" + }, + "engines": { + "node": ">=22", + "npm": ">=10.9.2" + }, + "peerDependencies": { + "github-slugger": "^2.0.0", + "hast-util-to-jsx-runtime": "^2.3.6", + "preact": "^10.0.0" + }, + "peerDependenciesMeta": { + "github-slugger": { + "optional": true + }, + "hast-util-to-jsx-runtime": { + "optional": true + } + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.57.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz", @@ -1104,6 +1130,17 @@ } } }, + "node_modules/preact": { + "version": "10.29.0", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.29.0.tgz", + "integrity": "sha512-wSAGyk2bYR1c7t3SZ3jHcM6xy0lcBcDel6lODcs9ME6Th++Dx2KU+6D3HD8wMMKGA8Wpw7OMd3/4RGzYRpzwRg==", + "license": "MIT", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, "node_modules/readdirp": { "version": "4.1.2", "license": "MIT", diff --git a/package.json b/package.json index 6fac5da..4196de2 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ }, "dependencies": { "@quartz-community/types": "github:quartz-community/types", + "@quartz-community/utils": "github:quartz-community/utils", "tsup": "^8.5.0", "typescript": "^5.9.3" } diff --git a/src/index.ts b/src/index.ts index 5fa6aa8..8614288 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import type { ContentIndex } from "@quartz-community/types"; +import { resolveBasePath } from "@quartz-community/utils/path"; /** * Browser runtime utilities for Quartz community plugins @@ -177,7 +178,7 @@ export function getCurrentSlug(): string { * Navigate to a slug */ export function navigateTo(slug: string): void { - window.location.href = "/" + slug; + window.location.href = resolveBasePath(slug); } // ============================================================================