radiant-docs-validator 0.1.9 → 0.1.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/dist/index.js +38 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1309,39 +1309,59 @@ async function validateNavigationNode(item, currentPath, groupDepth = 0) {
|
|
|
1309
1309
|
return;
|
|
1310
1310
|
}
|
|
1311
1311
|
}
|
|
1312
|
-
function
|
|
1312
|
+
function getFirstRouteFromPageItems(items) {
|
|
1313
1313
|
for (const item of items) {
|
|
1314
1314
|
if (typeof item === "string") {
|
|
1315
|
-
return
|
|
1315
|
+
return {
|
|
1316
|
+
type: "mdx",
|
|
1317
|
+
filePath: item
|
|
1318
|
+
};
|
|
1316
1319
|
}
|
|
1317
1320
|
if ("page" in item) {
|
|
1318
|
-
return
|
|
1321
|
+
return {
|
|
1322
|
+
type: "mdx",
|
|
1323
|
+
filePath: item.page
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
if ("openapi" in item) {
|
|
1327
|
+
return {
|
|
1328
|
+
type: "openapi"
|
|
1329
|
+
};
|
|
1319
1330
|
}
|
|
1320
1331
|
if ("group" in item) {
|
|
1321
|
-
const
|
|
1322
|
-
if (
|
|
1323
|
-
return
|
|
1332
|
+
const nestedRoute = getFirstRouteFromPageItems(item.pages);
|
|
1333
|
+
if (nestedRoute) {
|
|
1334
|
+
return nestedRoute;
|
|
1324
1335
|
}
|
|
1325
1336
|
}
|
|
1326
1337
|
}
|
|
1327
1338
|
return void 0;
|
|
1328
1339
|
}
|
|
1329
|
-
function
|
|
1340
|
+
function getFirstRouteFromNavigation(navigation) {
|
|
1330
1341
|
if (navigation.pages) {
|
|
1331
|
-
return
|
|
1342
|
+
return getFirstRouteFromPageItems(navigation.pages);
|
|
1332
1343
|
}
|
|
1333
1344
|
if (navigation.menu) {
|
|
1334
1345
|
for (const menuItem of navigation.menu.items) {
|
|
1335
1346
|
const submenuPages = menuItem.submenu.pages;
|
|
1336
|
-
if (
|
|
1337
|
-
|
|
1347
|
+
if (submenuPages) {
|
|
1348
|
+
const firstRoute = getFirstRouteFromPageItems(submenuPages);
|
|
1349
|
+
if (firstRoute) {
|
|
1350
|
+
return firstRoute;
|
|
1351
|
+
}
|
|
1338
1352
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1353
|
+
if (menuItem.submenu.openapi) {
|
|
1354
|
+
return {
|
|
1355
|
+
type: "openapi"
|
|
1356
|
+
};
|
|
1342
1357
|
}
|
|
1343
1358
|
}
|
|
1344
1359
|
}
|
|
1360
|
+
if (navigation.openapi) {
|
|
1361
|
+
return {
|
|
1362
|
+
type: "openapi"
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1345
1365
|
return void 0;
|
|
1346
1366
|
}
|
|
1347
1367
|
async function validateNavOpenApi(navOpenApi, currentPath) {
|
|
@@ -2526,12 +2546,12 @@ async function validateConfig(config) {
|
|
|
2526
2546
|
await validateNavigation(config.navigation);
|
|
2527
2547
|
config.home = validateHome(config.home);
|
|
2528
2548
|
if (config.home === void 0) {
|
|
2529
|
-
const
|
|
2530
|
-
if (
|
|
2531
|
-
config.home =
|
|
2532
|
-
} else if (!
|
|
2549
|
+
const fallbackRoute = getFirstRouteFromNavigation(config.navigation);
|
|
2550
|
+
if (fallbackRoute?.type === "mdx") {
|
|
2551
|
+
config.home = fallbackRoute.filePath;
|
|
2552
|
+
} else if (!fallbackRoute) {
|
|
2533
2553
|
throwConfigError(
|
|
2534
|
-
"Home is undefined and no
|
|
2554
|
+
"Home is undefined and no navigation route exists to use as fallback.",
|
|
2535
2555
|
["home"]
|
|
2536
2556
|
);
|
|
2537
2557
|
}
|