specra 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/svelte-config.js +12 -4
- package/dist/mdx.js +8 -3
- package/package.json +1 -1
package/config/svelte-config.js
CHANGED
|
@@ -49,18 +49,26 @@ export function specraMdsvexConfig(options = {}) {
|
|
|
49
49
|
* Read the deployment basePath from specra.config.json if present.
|
|
50
50
|
* Falls back to the BASE_PATH environment variable, then empty string.
|
|
51
51
|
*/
|
|
52
|
+
/**
|
|
53
|
+
* Normalize a base path: ensure leading slash, strip trailing slash.
|
|
54
|
+
* "task_flow" → "/task_flow", "/task_flow/" → "/task_flow", "" → ""
|
|
55
|
+
*/
|
|
56
|
+
function normalizeBasePath(bp) {
|
|
57
|
+
if (!bp) return ''
|
|
58
|
+
let normalized = bp.startsWith('/') ? bp : `/${bp}`
|
|
59
|
+
return normalized.replace(/\/+$/, '')
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
function resolveBasePath(configPath = path.join(process.cwd(), 'specra.config.json')) {
|
|
53
63
|
// Environment variable takes priority
|
|
54
|
-
if (process.env.BASE_PATH) return process.env.BASE_PATH
|
|
64
|
+
if (process.env.BASE_PATH) return normalizeBasePath(process.env.BASE_PATH)
|
|
55
65
|
|
|
56
66
|
try {
|
|
57
67
|
if (fs.existsSync(configPath)) {
|
|
58
68
|
const raw = JSON.parse(fs.readFileSync(configPath, 'utf8'))
|
|
59
69
|
if (raw.deployment?.basePath) {
|
|
60
|
-
const bp = raw.deployment.basePath
|
|
61
|
-
// If custom domain is set, ignore basePath
|
|
62
70
|
if (raw.deployment?.customDomain) return ''
|
|
63
|
-
return
|
|
71
|
+
return normalizeBasePath(raw.deployment.basePath)
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
} catch {
|
package/dist/mdx.js
CHANGED
|
@@ -396,16 +396,21 @@ function parseJsxExpression(expr) {
|
|
|
396
396
|
/**
|
|
397
397
|
* Process markdown content to HTML using remark/rehype pipeline.
|
|
398
398
|
*/
|
|
399
|
+
function normalizeBasePath(bp) {
|
|
400
|
+
if (!bp)
|
|
401
|
+
return '';
|
|
402
|
+
let normalized = bp.startsWith('/') ? bp : `/${bp}`;
|
|
403
|
+
return normalized.replace(/\/+$/, '');
|
|
404
|
+
}
|
|
399
405
|
function resolveDeploymentBasePath() {
|
|
400
406
|
if (process.env.BASE_PATH)
|
|
401
|
-
return process.env.BASE_PATH;
|
|
407
|
+
return normalizeBasePath(process.env.BASE_PATH);
|
|
402
408
|
try {
|
|
403
409
|
const configPath = path.join(process.cwd(), 'specra.config.json');
|
|
404
410
|
if (fs.existsSync(configPath)) {
|
|
405
411
|
const raw = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
406
412
|
if (raw.deployment?.basePath && !raw.deployment?.customDomain) {
|
|
407
|
-
|
|
408
|
-
return bp.startsWith('/') ? bp : `/${bp}`;
|
|
413
|
+
return normalizeBasePath(raw.deployment.basePath);
|
|
409
414
|
}
|
|
410
415
|
}
|
|
411
416
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specra",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "A modern documentation library for SvelteKit with built-in versioning, API reference generation, full-text search, and MDX support",
|
|
5
5
|
"svelte": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|