@moku-labs/web 0.6.0 → 1.0.1
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/README.md +227 -125
- package/dist/browser.d.mts +524 -111
- package/dist/browser.mjs +1707 -868
- package/dist/{convention-X3zLTlJ8.mjs → convention-CepUwWmT.mjs} +18 -1
- package/dist/{convention-Dr8jxG70.cjs → convention-krwh7Y6Q.cjs} +23 -0
- package/dist/index.cjs +3239 -1935
- package/dist/index.d.cts +365 -176
- package/dist/index.d.mts +366 -177
- package/dist/index.mjs +3236 -1934
- package/dist/{writer-DAF0pM25.cjs → writer-DV5hWB2i.cjs} +25 -27
- package/dist/{writer-BcWqa_7I.mjs → writer-Dc_lx22j.mjs} +25 -27
- package/package.json +1 -1
|
@@ -29,5 +29,22 @@ function dataSuffix(path) {
|
|
|
29
29
|
while (trimmed.endsWith("/")) trimmed = trimmed.slice(0, -1);
|
|
30
30
|
return trimmed.length > 0 ? `${trimmed}/index.json` : "index.json";
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Compute the `outputDir`-relative data file for a page path, joining the trimmed
|
|
34
|
+
* output dir with {@link dataSuffix}. Shared by the Node writer and the pure
|
|
35
|
+
* `fileFor` accessor so the written file and the reported path can never drift.
|
|
36
|
+
*
|
|
37
|
+
* @param outputDir - The configured data output subdir (e.g. `"_data"` or `"_data/"`).
|
|
38
|
+
* @param path - The page URL path (e.g. `/en/hello/`).
|
|
39
|
+
* @returns The `outputDir`-relative file path (e.g. `_data/en/hello/index.json`).
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* relativeDataFile("_data", "/en/hello/"); // "_data/en/hello/index.json"
|
|
43
|
+
* relativeDataFile("_data/", "/"); // "_data/index.json"
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
function relativeDataFile(outputDir, path) {
|
|
47
|
+
return `${outputDir.endsWith("/") ? outputDir.slice(0, -1) : outputDir}/${dataSuffix(path)}`;
|
|
48
|
+
}
|
|
32
49
|
//#endregion
|
|
33
|
-
export { dataSuffix as t };
|
|
50
|
+
export { relativeDataFile as n, dataSuffix as t };
|
|
@@ -60,6 +60,23 @@ function dataSuffix(path) {
|
|
|
60
60
|
while (trimmed.endsWith("/")) trimmed = trimmed.slice(0, -1);
|
|
61
61
|
return trimmed.length > 0 ? `${trimmed}/index.json` : "index.json";
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Compute the `outputDir`-relative data file for a page path, joining the trimmed
|
|
65
|
+
* output dir with {@link dataSuffix}. Shared by the Node writer and the pure
|
|
66
|
+
* `fileFor` accessor so the written file and the reported path can never drift.
|
|
67
|
+
*
|
|
68
|
+
* @param outputDir - The configured data output subdir (e.g. `"_data"` or `"_data/"`).
|
|
69
|
+
* @param path - The page URL path (e.g. `/en/hello/`).
|
|
70
|
+
* @returns The `outputDir`-relative file path (e.g. `_data/en/hello/index.json`).
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* relativeDataFile("_data", "/en/hello/"); // "_data/en/hello/index.json"
|
|
74
|
+
* relativeDataFile("_data/", "/"); // "_data/index.json"
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
function relativeDataFile(outputDir, path) {
|
|
78
|
+
return `${outputDir.endsWith("/") ? outputDir.slice(0, -1) : outputDir}/${dataSuffix(path)}`;
|
|
79
|
+
}
|
|
63
80
|
//#endregion
|
|
64
81
|
Object.defineProperty(exports, "__exportAll", {
|
|
65
82
|
enumerable: true,
|
|
@@ -79,3 +96,9 @@ Object.defineProperty(exports, "dataSuffix", {
|
|
|
79
96
|
return dataSuffix;
|
|
80
97
|
}
|
|
81
98
|
});
|
|
99
|
+
Object.defineProperty(exports, "relativeDataFile", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function() {
|
|
102
|
+
return relativeDataFile;
|
|
103
|
+
}
|
|
104
|
+
});
|