mirror of
https://github.com/quartz-community/runtime.git
synced 2026-07-22 02:50:26 +00:00
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.
This commit is contained in:
parent
cac58690c9
commit
4ae96eb52c
3 changed files with 40 additions and 1 deletions
37
package-lock.json
generated
37
package-lock.json
generated
|
|
@ -10,6 +10,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@quartz-community/types": "github:quartz-community/types",
|
"@quartz-community/types": "github:quartz-community/types",
|
||||||
|
"@quartz-community/utils": "github:quartz-community/utils",
|
||||||
"tsup": "^8.5.0",
|
"tsup": "^8.5.0",
|
||||||
"typescript": "^5.9.3"
|
"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": {
|
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||||
"version": "4.57.1",
|
"version": "4.57.1",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz",
|
"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": {
|
"node_modules/readdirp": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@quartz-community/types": "github:quartz-community/types",
|
"@quartz-community/types": "github:quartz-community/types",
|
||||||
|
"@quartz-community/utils": "github:quartz-community/utils",
|
||||||
"tsup": "^8.5.0",
|
"tsup": "^8.5.0",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import type { ContentIndex } from "@quartz-community/types";
|
import type { ContentIndex } from "@quartz-community/types";
|
||||||
|
import { resolveBasePath } from "@quartz-community/utils/path";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Browser runtime utilities for Quartz community plugins
|
* Browser runtime utilities for Quartz community plugins
|
||||||
|
|
@ -177,7 +178,7 @@ export function getCurrentSlug(): string {
|
||||||
* Navigate to a slug
|
* Navigate to a slug
|
||||||
*/
|
*/
|
||||||
export function navigateTo(slug: string): void {
|
export function navigateTo(slug: string): void {
|
||||||
window.location.href = "/" + slug;
|
window.location.href = resolveBasePath(slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue