@aravindc26/velu 0.11.9 → 0.11.10
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/package.json +1 -1
- package/src/cli.ts +26 -19
- package/src/validate.ts +24 -1
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -39,7 +39,7 @@ function printHelp() {
|
|
|
39
39
|
velu lint Validate docs.json (or velu.json) and check referenced pages
|
|
40
40
|
velu run [--port N] Build site and start dev server (default: 4321)
|
|
41
41
|
velu build Build a deployable static site (SSG)
|
|
42
|
-
velu paths Output
|
|
42
|
+
velu paths Output navigation paths and source files as JSON (grouped by language)
|
|
43
43
|
|
|
44
44
|
Options:
|
|
45
45
|
--port <number> Port for the dev server (default: 4321)
|
|
@@ -159,7 +159,7 @@ interface PathEntry {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
async function paths(docsDir: string) {
|
|
162
|
-
const {
|
|
162
|
+
const { collectPagesByLanguage } = await import("./validate.js");
|
|
163
163
|
const { normalizeConfigNavigation } = await import("./navigation-normalize.js");
|
|
164
164
|
const { readFileSync, existsSync } = await import("node:fs");
|
|
165
165
|
const { join } = await import("node:path");
|
|
@@ -172,25 +172,32 @@ async function paths(docsDir: string) {
|
|
|
172
172
|
|
|
173
173
|
const raw = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
174
174
|
const config = normalizeConfigNavigation(raw);
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
175
|
+
const pagesByLanguage = collectPagesByLanguage(config);
|
|
176
|
+
const groupedEntries: Record<string, PathEntry[]> = {};
|
|
177
|
+
const flatEntries: PathEntry[] = [];
|
|
178
|
+
|
|
179
|
+
for (const [language, pages] of Object.entries(pagesByLanguage)) {
|
|
180
|
+
const entries: PathEntry[] = pages.map((pagePath) => {
|
|
181
|
+
// Check for .mdx first, then .md
|
|
182
|
+
const mdxPath = join(docsDir, `${pagePath}.mdx`);
|
|
183
|
+
const mdPath = join(docsDir, `${pagePath}.md`);
|
|
184
|
+
|
|
185
|
+
if (existsSync(mdxPath)) {
|
|
186
|
+
return { path: pagePath, file: `${pagePath}.mdx` };
|
|
187
|
+
}
|
|
188
|
+
if (existsSync(mdPath)) {
|
|
189
|
+
return { path: pagePath, file: `${pagePath}.md` };
|
|
190
|
+
}
|
|
191
|
+
return { path: pagePath, file: null };
|
|
192
|
+
});
|
|
193
|
+
groupedEntries[language] = entries;
|
|
194
|
+
flatEntries.push(...entries);
|
|
195
|
+
}
|
|
190
196
|
|
|
191
197
|
const output = {
|
|
192
|
-
|
|
193
|
-
|
|
198
|
+
pathsByLanguage: groupedEntries,
|
|
199
|
+
paths: flatEntries,
|
|
200
|
+
count: flatEntries.length,
|
|
194
201
|
};
|
|
195
202
|
|
|
196
203
|
console.log(JSON.stringify(output, null, 2));
|
package/src/validate.ts
CHANGED
|
@@ -116,6 +116,7 @@ type VeluOpenApiSource = string | string[] | Record<string, unknown>;
|
|
|
116
116
|
interface VeluConfig {
|
|
117
117
|
$schema?: string;
|
|
118
118
|
variables?: Record<string, string>;
|
|
119
|
+
languages?: string[];
|
|
119
120
|
icons?: {
|
|
120
121
|
library?: "fontawesome" | "lucide" | "tabler";
|
|
121
122
|
};
|
|
@@ -262,6 +263,28 @@ function collectPages(config: VeluConfig): string[] {
|
|
|
262
263
|
return collectPagesFromTabs(tabs);
|
|
263
264
|
}
|
|
264
265
|
|
|
266
|
+
function collectPagesByLanguage(config: VeluConfig): Record<string, string[]> {
|
|
267
|
+
const grouped: Record<string, string[]> = {};
|
|
268
|
+
|
|
269
|
+
if (config.navigation.languages && config.navigation.languages.length > 0) {
|
|
270
|
+
for (const lang of config.navigation.languages) {
|
|
271
|
+
grouped[lang.language] = collectPagesFromTabs(lang.tabs);
|
|
272
|
+
}
|
|
273
|
+
return grouped;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const basePages = collectPagesFromTabs(config.navigation.tabs ?? []);
|
|
277
|
+
if (config.languages && config.languages.length > 0) {
|
|
278
|
+
for (const lang of config.languages) {
|
|
279
|
+
grouped[lang] = [...basePages];
|
|
280
|
+
}
|
|
281
|
+
return grouped;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
grouped.english = basePages;
|
|
285
|
+
return grouped;
|
|
286
|
+
}
|
|
287
|
+
|
|
265
288
|
function validateVeluConfig(docsDir: string, schemaPath: string): { valid: boolean; errors: string[] } {
|
|
266
289
|
const errors: string[] = [];
|
|
267
290
|
|
|
@@ -331,4 +354,4 @@ function validateVeluConfig(docsDir: string, schemaPath: string): { valid: boole
|
|
|
331
354
|
return { valid: errors.length === 0, errors };
|
|
332
355
|
}
|
|
333
356
|
|
|
334
|
-
export { validateVeluConfig, collectPages, VeluConfig, VeluGroup, VeluTab, VeluSeparator, VeluLink, VeluAnchor };
|
|
357
|
+
export { validateVeluConfig, collectPages, collectPagesByLanguage, VeluConfig, VeluGroup, VeluTab, VeluSeparator, VeluLink, VeluAnchor };
|