radiant-docs-validator 0.1.8 → 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.
Files changed (2) hide show
  1. package/dist/index.js +38 -17
  2. 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 getFirstPagePathFromPageItems(items) {
1312
+ function getFirstRouteFromPageItems(items) {
1313
1313
  for (const item of items) {
1314
1314
  if (typeof item === "string") {
1315
- return item;
1315
+ return {
1316
+ type: "mdx",
1317
+ filePath: item
1318
+ };
1316
1319
  }
1317
1320
  if ("page" in item) {
1318
- return item.page;
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 nestedPath = getFirstPagePathFromPageItems(item.pages);
1322
- if (nestedPath) {
1323
- return nestedPath;
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 getFirstPagePathFromNavigation(navigation) {
1340
+ function getFirstRouteFromNavigation(navigation) {
1330
1341
  if (navigation.pages) {
1331
- return getFirstPagePathFromPageItems(navigation.pages);
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 (!submenuPages) {
1337
- continue;
1347
+ if (submenuPages) {
1348
+ const firstRoute = getFirstRouteFromPageItems(submenuPages);
1349
+ if (firstRoute) {
1350
+ return firstRoute;
1351
+ }
1338
1352
  }
1339
- const firstPath = getFirstPagePathFromPageItems(submenuPages);
1340
- if (firstPath) {
1341
- return firstPath;
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,14 +2546,15 @@ 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 fallbackHome = getFirstPagePathFromNavigation(config.navigation);
2530
- if (!fallbackHome) {
2549
+ const fallbackRoute = getFirstRouteFromNavigation(config.navigation);
2550
+ if (fallbackRoute?.type === "mdx") {
2551
+ config.home = fallbackRoute.filePath;
2552
+ } else if (!fallbackRoute) {
2531
2553
  throwConfigError(
2532
- "Home is undefined and no documentation page exists in navigation to use as fallback.",
2554
+ "Home is undefined and no navigation route exists to use as fallback.",
2533
2555
  ["home"]
2534
2556
  );
2535
2557
  }
2536
- config.home = fallbackHome;
2537
2558
  }
2538
2559
  const hiddenPageRoutes = [
2539
2560
  ...validateNavbar(config.navbar),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radiant-docs-validator",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Shared validation for Radiant documentation repositories",
5
5
  "type": "module",
6
6
  "scripts": {