@constela/start 1.8.2 → 1.8.4
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.
|
@@ -938,6 +938,18 @@ function loadComponentDefinitions(baseDir, componentsPath) {
|
|
|
938
938
|
throw new Error(`Invalid JSON in MDX components file: ${fullPath}`);
|
|
939
939
|
}
|
|
940
940
|
}
|
|
941
|
+
function extractGlobBasePath(pattern) {
|
|
942
|
+
const starIndex = pattern.indexOf("*");
|
|
943
|
+
if (starIndex === -1) {
|
|
944
|
+
return "";
|
|
945
|
+
}
|
|
946
|
+
const beforeStar = pattern.substring(0, starIndex);
|
|
947
|
+
const lastSlash = beforeStar.lastIndexOf("/");
|
|
948
|
+
if (lastSlash === -1) {
|
|
949
|
+
return "";
|
|
950
|
+
}
|
|
951
|
+
return beforeStar.substring(0, lastSlash + 1);
|
|
952
|
+
}
|
|
941
953
|
async function transformMdx(content, file, options) {
|
|
942
954
|
const match = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
943
955
|
let frontmatter = {};
|
|
@@ -957,12 +969,15 @@ async function transformMdx(content, file, options) {
|
|
|
957
969
|
if (typeof fmSlug === "string") {
|
|
958
970
|
slug = fmSlug;
|
|
959
971
|
} else {
|
|
960
|
-
const
|
|
972
|
+
const basePath = options?.basePath ?? "";
|
|
973
|
+
const relativePath = file.startsWith(basePath) ? file.substring(basePath.length) : file;
|
|
974
|
+
const filename = basename(relativePath, extname2(relativePath));
|
|
961
975
|
if (filename === "index") {
|
|
962
|
-
const dir = dirname(
|
|
963
|
-
slug = dir === "." ? "index" :
|
|
976
|
+
const dir = dirname(relativePath);
|
|
977
|
+
slug = dir === "." ? "index" : dir;
|
|
964
978
|
} else {
|
|
965
|
-
|
|
979
|
+
const dir = dirname(relativePath);
|
|
980
|
+
slug = dir === "." ? filename : `${dir}/${filename}`;
|
|
966
981
|
}
|
|
967
982
|
}
|
|
968
983
|
return {
|
|
@@ -1034,11 +1049,15 @@ function applyTransform(content, transform, filename) {
|
|
|
1034
1049
|
async function loadGlob(baseDir, pattern, transform, options) {
|
|
1035
1050
|
const files = await fg2(pattern, { cwd: baseDir });
|
|
1036
1051
|
if (transform === "mdx") {
|
|
1052
|
+
const basePath = extractGlobBasePath(pattern);
|
|
1037
1053
|
const results2 = [];
|
|
1038
1054
|
for (const file of files) {
|
|
1039
1055
|
const fullPath = join3(baseDir, file);
|
|
1040
1056
|
const content = readFileSync(fullPath, "utf-8");
|
|
1041
|
-
const transformed = await transformMdx(content, file,
|
|
1057
|
+
const transformed = await transformMdx(content, file, {
|
|
1058
|
+
...options,
|
|
1059
|
+
basePath
|
|
1060
|
+
});
|
|
1042
1061
|
results2.push(transformed);
|
|
1043
1062
|
}
|
|
1044
1063
|
return results2;
|
package/dist/cli/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -476,6 +476,7 @@ declare function loadComponentDefinitions(baseDir: string, componentsPath: strin
|
|
|
476
476
|
*/
|
|
477
477
|
declare function transformMdx(content: string, file: string, options?: {
|
|
478
478
|
components?: Record<string, ComponentDef>;
|
|
479
|
+
basePath?: string;
|
|
479
480
|
}): Promise<MdxGlobResult>;
|
|
480
481
|
/**
|
|
481
482
|
* Transform YAML content
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/start",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "Meta-framework for Constela applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"tailwindcss": "^4.0.0",
|
|
46
46
|
"ws": "^8.18.0",
|
|
47
47
|
"@constela/compiler": "0.12.0",
|
|
48
|
-
"@constela/core": "0.13.0",
|
|
49
48
|
"@constela/router": "15.0.0",
|
|
49
|
+
"@constela/core": "0.13.0",
|
|
50
50
|
"@constela/runtime": "0.16.5",
|
|
51
51
|
"@constela/server": "9.0.0"
|
|
52
52
|
},
|