@mintlify/common 1.0.338 → 1.0.341

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.
@@ -1,9 +1,11 @@
1
1
  import { divisions, } from '@mintlify/validation';
2
+ import { replaceSlashIndex } from '../slug/replaceSlashIndex.js';
2
3
  import { isPage } from './index.js';
3
4
  export function getFirstPageFromNavigation(node) {
4
5
  if (!node || typeof node !== 'object')
5
6
  return undefined;
6
7
  if (isPage(node)) {
8
+ node.href = replaceSlashIndex(node.href);
7
9
  return node;
8
10
  }
9
11
  if ('pages' in node) {
@@ -11,6 +13,7 @@ export function getFirstPageFromNavigation(node) {
11
13
  if (typeof page === 'object') {
12
14
  const pagePath = getFirstPageFromNavigation(page);
13
15
  if (pagePath) {
16
+ pagePath.href = replaceSlashIndex(pagePath.href);
14
17
  return pagePath;
15
18
  }
16
19
  }
@@ -22,6 +25,7 @@ export function getFirstPageFromNavigation(node) {
22
25
  continue;
23
26
  const page = getFirstPageFromNavigation(group);
24
27
  if (page) {
28
+ page.href = replaceSlashIndex(page.href);
25
29
  return page;
26
30
  }
27
31
  }
@@ -35,6 +39,7 @@ export function getFirstPageFromNavigation(node) {
35
39
  continue;
36
40
  const page = getFirstPageFromNavigation(item);
37
41
  if (page) {
42
+ page.href = replaceSlashIndex(page.href);
38
43
  return page;
39
44
  }
40
45
  }
@@ -1,2 +1,3 @@
1
1
  export * from './slugToTitle.js';
2
2
  export * from './getDecoratedNavPageAndSlug.js';
3
+ export * from './replaceSlashIndex.js';
@@ -1,2 +1,3 @@
1
1
  export * from './slugToTitle.js';
2
2
  export * from './getDecoratedNavPageAndSlug.js';
3
+ export * from './replaceSlashIndex.js';
@@ -0,0 +1 @@
1
+ export declare function replaceSlashIndex(path: string): string;
@@ -0,0 +1,11 @@
1
+ export function replaceSlashIndex(path) {
2
+ if (typeof path !== 'string')
3
+ return path;
4
+ if (path.endsWith('/index')) {
5
+ return path.slice(0, -6);
6
+ }
7
+ else if (path === 'index') {
8
+ return '';
9
+ }
10
+ return path;
11
+ }