mintlify 1.1.1 → 1.1.2

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 (193) hide show
  1. package/bin/index.js +2 -3
  2. package/bin/index.js.map +1 -1
  3. package/bin/local-preview/helper-commands/clearCommand.js +4 -4
  4. package/bin/local-preview/helper-commands/clearCommand.js.map +1 -1
  5. package/bin/local-preview/index.js +43 -4
  6. package/bin/local-preview/index.js.map +1 -1
  7. package/bin/local-preview/injectNav.js +94 -0
  8. package/bin/local-preview/injectNav.js.map +1 -0
  9. package/bin/local-preview/utils/listener.js +1 -1
  10. package/bin/local-preview/utils/listener.js.map +1 -1
  11. package/bin/mint/client/.babel-plugin-macrosrc.json +5 -0
  12. package/bin/mint/client/.babelrc +4 -0
  13. package/bin/mint/client/.editorconfig +12 -0
  14. package/bin/mint/client/.eslintrc.json +7 -0
  15. package/bin/mint/client/.prettierignore +4 -0
  16. package/bin/mint/client/.prettierrc +14 -0
  17. package/bin/mint/client/.vscode/launch.json +28 -0
  18. package/bin/mint/client/README.md +44 -0
  19. package/bin/mint/client/jest.config.ts +195 -0
  20. package/bin/mint/client/next-env.d.ts +4 -0
  21. package/bin/mint/client/next.config.js +152 -0
  22. package/bin/mint/client/package.json +139 -0
  23. package/bin/mint/client/postcss.config.cjs +9 -0
  24. package/bin/mint/client/prebuild/faviconConfig.js +35 -0
  25. package/bin/mint/client/prebuild/getOpenApiContext.js +53 -0
  26. package/bin/mint/client/prebuild/index.js +117 -0
  27. package/bin/mint/client/prebuild/injectNav.js +115 -0
  28. package/bin/mint/client/prebuild/slugToTitle.js +7 -0
  29. package/bin/mint/client/rehype/withApiComponents.js +60 -0
  30. package/bin/mint/client/rehype/withCodeBlocks.js +54 -0
  31. package/bin/mint/client/rehype/withLayouts.js +113 -0
  32. package/bin/mint/client/rehype/withLinkRoles.js +13 -0
  33. package/bin/mint/client/rehype/withRawComponents.js +13 -0
  34. package/bin/mint/client/rehype/withStaticProps.js +25 -0
  35. package/bin/mint/client/rehype/withSyntaxHighlighting.js +60 -0
  36. package/bin/mint/client/remark/utils.js +369 -0
  37. package/bin/mint/client/remark/withFrames.js +55 -0
  38. package/bin/mint/client/remark/withImportsInjected.js +36 -0
  39. package/bin/mint/client/remark/withNextLinks.js +37 -0
  40. package/bin/mint/client/remark/withTableOfContents.js +71 -0
  41. package/bin/mint/client/scripts/local.js +177 -0
  42. package/bin/mint/client/sentry.client.config.js +15 -0
  43. package/bin/mint/client/sentry.properties +4 -0
  44. package/bin/mint/client/sentry.server.config.js +15 -0
  45. package/bin/mint/client/src/analytics/AbstractAnalyticsImplementation.ts +50 -0
  46. package/bin/mint/client/src/analytics/AnalyticsContext.ts +5 -0
  47. package/bin/mint/client/src/analytics/AnalyticsMediator.ts +101 -0
  48. package/bin/mint/client/src/analytics/FakeAnalyticsMediator.ts +9 -0
  49. package/bin/mint/client/src/analytics/GA4Script.tsx +33 -0
  50. package/bin/mint/client/src/analytics/implementations/amplitude.ts +26 -0
  51. package/bin/mint/client/src/analytics/implementations/fathom.ts +38 -0
  52. package/bin/mint/client/src/analytics/implementations/ga4.ts +33 -0
  53. package/bin/mint/client/src/analytics/implementations/hotjar.ts +53 -0
  54. package/bin/mint/client/src/analytics/implementations/mixpanel-browser.d.ts +1 -0
  55. package/bin/mint/client/src/analytics/implementations/mixpanel.ts +52 -0
  56. package/bin/mint/client/src/analytics/implementations/posthog.ts +37 -0
  57. package/bin/mint/client/src/components/Accordion/Accordion.tsx +43 -0
  58. package/bin/mint/client/src/components/Accordion/index.ts +4 -0
  59. package/bin/mint/client/src/components/ApiExample.tsx +9 -0
  60. package/bin/mint/client/src/components/Card.tsx +51 -0
  61. package/bin/mint/client/src/components/CodeGroup.tsx +132 -0
  62. package/bin/mint/client/src/components/Editor.tsx +12 -0
  63. package/bin/mint/client/src/components/Expandable.tsx +40 -0
  64. package/bin/mint/client/src/components/Heading.tsx +84 -0
  65. package/bin/mint/client/src/components/Param.tsx +56 -0
  66. package/bin/mint/client/src/components/Request.tsx +19 -0
  67. package/bin/mint/client/src/components/ResponseField.tsx +33 -0
  68. package/bin/mint/client/src/components/TabBar.tsx +61 -0
  69. package/bin/mint/client/src/config.ts +115 -0
  70. package/bin/mint/client/src/css/bar-of-progress.css +10 -0
  71. package/bin/mint/client/src/css/base.css +29 -0
  72. package/bin/mint/client/src/css/font-awesome.css +7 -0
  73. package/bin/mint/client/src/css/fonts.css +44 -0
  74. package/bin/mint/client/src/css/main.css +11 -0
  75. package/bin/mint/client/src/css/prism.css +270 -0
  76. package/bin/mint/client/src/css/utilities.css +43 -0
  77. package/bin/mint/client/src/enums/components.ts +8 -0
  78. package/bin/mint/client/src/fonts/FiraCode-VF.woff +0 -0
  79. package/bin/mint/client/src/fonts/FiraCode-VF.woff2 +0 -0
  80. package/bin/mint/client/src/fonts/IBMPlexMono-Regular.ttf +0 -0
  81. package/bin/mint/client/src/fonts/IBMPlexMono-SemiBold.ttf +0 -0
  82. package/bin/mint/client/src/fonts/Inter-italic-latin.var.woff2 +0 -0
  83. package/bin/mint/client/src/fonts/Inter-roman-latin.var.woff2 +0 -0
  84. package/bin/mint/client/src/fonts/Pally-Variable.ttf +0 -0
  85. package/bin/mint/client/src/fonts/SourceSansPro-Regular.otf +0 -0
  86. package/bin/mint/client/src/fonts/SourceSerifPro-Regular.ttf +0 -0
  87. package/bin/mint/client/src/fonts/Synonym-Variable.ttf +0 -0
  88. package/bin/mint/client/src/fonts/Ubuntu-Mono-bold.woff2 +0 -0
  89. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.woff2 +0 -0
  90. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.zopfli.woff +0 -0
  91. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular.module.css +11 -0
  92. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.woff2 +0 -0
  93. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.zopfli.woff +0 -0
  94. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold.module.css +11 -0
  95. package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.woff2 +0 -0
  96. package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.zopfli.woff +0 -0
  97. package/bin/mint/client/src/fonts/generated/Pally-Variable.module.css +11 -0
  98. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.woff2 +0 -0
  99. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.zopfli.woff +0 -0
  100. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular.module.css +11 -0
  101. package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.woff2 +0 -0
  102. package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.zopfli.woff +0 -0
  103. package/bin/mint/client/src/fonts/generated/Synonym-Variable.module.css +11 -0
  104. package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.woff2 +0 -0
  105. package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.zopfli.woff +0 -0
  106. package/bin/mint/client/src/fonts/generated/TenorSans-Regular.module.css +11 -0
  107. package/bin/mint/client/src/hooks/useActionKey.ts +20 -0
  108. package/bin/mint/client/src/hooks/useIsomorphicLayoutEffect.ts +3 -0
  109. package/bin/mint/client/src/hooks/useMedia.ts +27 -0
  110. package/bin/mint/client/src/hooks/usePrevNext.ts +34 -0
  111. package/bin/mint/client/src/hooks/useTop.ts +15 -0
  112. package/bin/mint/client/src/icons/CopyToClipboard.tsx +33 -0
  113. package/bin/mint/client/src/index.d.ts +1 -0
  114. package/bin/mint/client/src/layouts/ApiSupplemental.tsx +173 -0
  115. package/bin/mint/client/src/layouts/ContentsLayout.tsx +256 -0
  116. package/bin/mint/client/src/layouts/DocumentationLayout.tsx +44 -0
  117. package/bin/mint/client/src/layouts/OpenApiContent.tsx +301 -0
  118. package/bin/mint/client/src/layouts/SidebarLayout.tsx +412 -0
  119. package/bin/mint/client/src/layouts/UserFeedback.tsx +73 -0
  120. package/bin/mint/client/src/layouts/getGroupsInDivision.ts +25 -0
  121. package/bin/mint/client/src/layouts/isPathInGroupPages.ts +10 -0
  122. package/bin/mint/client/src/metadata.ts +58 -0
  123. package/bin/mint/client/src/nav.json +219 -0
  124. package/bin/mint/client/src/openapi.ts +3 -0
  125. package/bin/mint/client/src/pages/404.tsx +73 -0
  126. package/bin/mint/client/src/pages/_app.tsx +138 -0
  127. package/bin/mint/client/src/pages/_document.tsx +57 -0
  128. package/bin/mint/client/src/pages/api/issue.ts +10 -0
  129. package/bin/mint/client/src/pages/api/name.ts +8 -0
  130. package/bin/mint/client/src/pages/api/request.ts +31 -0
  131. package/bin/mint/client/src/pages/api/suggest.ts +10 -0
  132. package/bin/mint/client/src/pages/api/syntax-highlighted-json.ts +13 -0
  133. package/bin/mint/client/src/pages/api/utils.ts +6 -0
  134. package/bin/mint/client/src/pages/index.tsx +31 -0
  135. package/bin/mint/client/src/ui/Api.tsx +359 -0
  136. package/bin/mint/client/src/ui/Footer.tsx +124 -0
  137. package/bin/mint/client/src/ui/Header.tsx +370 -0
  138. package/bin/mint/client/src/ui/Logo.tsx +55 -0
  139. package/bin/mint/client/src/ui/PageHeader.tsx +51 -0
  140. package/bin/mint/client/src/ui/Search.tsx +386 -0
  141. package/bin/mint/client/src/ui/ThemeToggle.tsx +285 -0
  142. package/bin/mint/client/src/ui/Title.tsx +22 -0
  143. package/bin/mint/client/src/ui/TopLevelLink.tsx +122 -0
  144. package/bin/mint/client/src/utils/api.ts +252 -0
  145. package/bin/mint/client/src/utils/brands.ts +217 -0
  146. package/bin/mint/client/src/utils/castArray.ts +3 -0
  147. package/bin/mint/client/src/utils/childrenArray.ts +3 -0
  148. package/bin/mint/client/src/utils/fit.ts +27 -0
  149. package/bin/mint/client/src/utils/fontAwesome.ts +577 -0
  150. package/bin/mint/client/src/utils/getAnalyticsConfig.ts +14 -0
  151. package/bin/mint/client/src/utils/getLogoHref.ts +9 -0
  152. package/bin/mint/client/src/utils/getOpenApiContext.ts +26 -0
  153. package/bin/mint/client/src/utils/importAll.ts +6 -0
  154. package/bin/mint/client/src/utils/isObject.ts +3 -0
  155. package/bin/mint/client/src/utils/kebabToTitleCase.ts +3 -0
  156. package/bin/mint/client/src/utils/loadImage.ts +8 -0
  157. package/bin/mint/client/src/utils/slugToTitle.ts +7 -0
  158. package/bin/mint/client/src/utils/wait.ts +5 -0
  159. package/bin/mint/client/tailwind.config.cjs +323 -0
  160. package/bin/mint/client/test/test.test.ts +5 -0
  161. package/bin/mint/client/tsconfig.json +36 -0
  162. package/bin/mint/client/yarn.lock +9702 -0
  163. package/bin/scraping/downloadAllImages.js +4 -0
  164. package/bin/scraping/downloadAllImages.js.map +1 -1
  165. package/bin/scraping/scrapeSectionCommands.js +18 -46
  166. package/bin/scraping/scrapeSectionCommands.js.map +1 -1
  167. package/bin/scraping/site-scrapers/alternateGroupTitle.js +9 -0
  168. package/bin/scraping/site-scrapers/alternateGroupTitle.js.map +1 -0
  169. package/bin/scraping/site-scrapers/getLinksRecursively.js +7 -2
  170. package/bin/scraping/site-scrapers/getLinksRecursively.js.map +1 -1
  171. package/bin/scraping/site-scrapers/openNestedDocusaurusMenus.js +30 -0
  172. package/bin/scraping/site-scrapers/openNestedDocusaurusMenus.js.map +1 -0
  173. package/bin/scraping/site-scrapers/openNestedGitbookMenus.js +37 -0
  174. package/bin/scraping/site-scrapers/openNestedGitbookMenus.js.map +1 -0
  175. package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js +20 -21
  176. package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +1 -1
  177. package/bin/scraping/site-scrapers/scrapeGitBookSection.js +2 -9
  178. package/bin/scraping/site-scrapers/scrapeGitBookSection.js.map +1 -1
  179. package/package.json +1 -1
  180. package/src/index.ts +2 -2
  181. package/src/local-preview/helper-commands/clearCommand.ts +6 -4
  182. package/src/local-preview/index.ts +48 -3
  183. package/src/local-preview/utils/listener.ts +1 -1
  184. package/src/scraping/downloadAllImages.ts +5 -0
  185. package/src/scraping/scrapeSectionCommands.ts +34 -60
  186. package/src/scraping/site-scrapers/alternateGroupTitle.ts +8 -0
  187. package/src/scraping/site-scrapers/getLinksRecursively.ts +7 -2
  188. package/src/scraping/site-scrapers/openNestedDocusaurusMenus.ts +42 -0
  189. package/src/scraping/site-scrapers/openNestedGitbookMenus.ts +49 -0
  190. package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +23 -21
  191. package/src/scraping/site-scrapers/scrapeGitBookSection.ts +2 -10
  192. package/bin/local-preview/helper-commands/cleanCommand.js +0 -8
  193. package/bin/local-preview/helper-commands/cleanCommand.js.map +0 -1
@@ -3,22 +3,12 @@ import { detectFramework, Frameworks } from "./detectFramework.js";
3
3
  import { getHrefFromArgs, getOrigin } from "../util.js";
4
4
  import { scrapeSection } from "./scrapeSection.js";
5
5
  import { scrapeDocusaurusSection } from "./site-scrapers/scrapeDocusaurusSection.js";
6
+ import openNestedDocusaurusMenus from "./site-scrapers/openNestedDocusaurusMenus.js";
6
7
  import { scrapeGitBookSection } from "./site-scrapers/scrapeGitBookSection.js";
8
+ import openNestedGitbookMenus from "./site-scrapers/openNestedGitbookMenus.js";
7
9
  import { scrapeReadMeSection } from "./site-scrapers/scrapeReadMeSection.js";
8
10
  import { startBrowser } from "../browser.js";
9
11
 
10
- function validateFramework(framework: Frameworks | undefined) {
11
- if (!framework) {
12
- console.log(
13
- "Could not detect the framework automatically. Please use one of:"
14
- );
15
- console.log("scrape-page-docusaurus");
16
- console.log("scrape-page-gitbook");
17
- console.log("scrape-page-readme");
18
- return process.exit(1);
19
- }
20
- }
21
-
22
12
  export async function scrapeSectionAxiosWrapper(argv: any, scrapeFunc: any) {
23
13
  const href = getHrefFromArgs(argv);
24
14
  const res = await axios.default.get(href);
@@ -27,11 +17,27 @@ export async function scrapeSectionAxiosWrapper(argv: any, scrapeFunc: any) {
27
17
  process.exit(0);
28
18
  }
29
19
 
20
+ export async function scrapeDocusaurusSectionCommand(argv: any) {
21
+ await scrapeSectionOpeningAllNested(
22
+ argv,
23
+ openNestedDocusaurusMenus,
24
+ scrapeDocusaurusSection
25
+ );
26
+ }
27
+
30
28
  export async function scrapeGitbookSectionCommand(argv: any) {
31
- await scrapeSectionGitBookWrapper(argv, scrapeGitBookSection);
29
+ await scrapeSectionOpeningAllNested(
30
+ argv,
31
+ openNestedGitbookMenus,
32
+ scrapeGitBookSection
33
+ );
32
34
  }
33
35
 
34
- async function scrapeSectionGitBookWrapper(argv: any, scrapeFunc: any) {
36
+ async function scrapeSectionOpeningAllNested(
37
+ argv: any,
38
+ openLinks: any,
39
+ scrapeFunc: any
40
+ ) {
35
41
  const href = getHrefFromArgs(argv);
36
42
 
37
43
  const browser = await startBrowser();
@@ -40,51 +46,7 @@ async function scrapeSectionGitBookWrapper(argv: any, scrapeFunc: any) {
40
46
  waitUntil: "networkidle2",
41
47
  });
42
48
 
43
- let prevEncountered: string[] = [];
44
- let encounteredHref = ["fake"];
45
-
46
- // Loop until we've encountered every link
47
- while (!encounteredHref.every((href) => prevEncountered.includes(href))) {
48
- prevEncountered = encounteredHref;
49
- encounteredHref = await page.evaluate(
50
- (encounteredHref) => {
51
- const icons: HTMLElement[] = Array.from(
52
- document.querySelectorAll('path[d="M9 18l6-6-6-6"]')
53
- );
54
-
55
- const linksFound: string[] = [];
56
- icons.forEach(async (icon: HTMLElement) => {
57
- const toClick = icon?.parentElement?.parentElement;
58
- const link = toClick?.parentElement?.parentElement;
59
-
60
- // Skip icons not in the side navigation
61
- if (!link?.hasAttribute("href")) {
62
- return;
63
- }
64
-
65
- const href = link.getAttribute("href");
66
-
67
- // Should never occur but we keep it as a fail-safe
68
- if (href?.startsWith("https://") || href?.startsWith("http://")) {
69
- return;
70
- }
71
-
72
- // Click any links we haven't seen before
73
- if (href && !encounteredHref.includes(href)) {
74
- toClick?.click();
75
- }
76
- if (href) {
77
- linksFound.push(href);
78
- }
79
- });
80
-
81
- return linksFound;
82
- },
83
- encounteredHref // Need to pass array into the browser
84
- );
85
- }
86
-
87
- const html = await page.content();
49
+ const html = await openLinks(page);
88
50
  browser.close();
89
51
  await scrapeSection(scrapeFunc, html, getOrigin(href), argv.overwrite);
90
52
  process.exit(0);
@@ -101,10 +63,22 @@ export async function scrapeSectionAutomatically(argv: any) {
101
63
  console.log("Detected framework: " + framework);
102
64
 
103
65
  if (framework === Frameworks.DOCUSAURUS) {
104
- await scrapeSectionAxiosWrapper(argv, scrapeDocusaurusSection);
66
+ await scrapeDocusaurusSectionCommand(argv);
105
67
  } else if (framework === Frameworks.GITBOOK) {
106
68
  await scrapeGitbookSectionCommand(argv);
107
69
  } else if (framework === Frameworks.README) {
108
70
  await scrapeSectionAxiosWrapper(argv, scrapeReadMeSection);
109
71
  }
110
72
  }
73
+
74
+ function validateFramework(framework: Frameworks | undefined) {
75
+ if (!framework) {
76
+ console.log(
77
+ "Could not detect the framework automatically. Please use one of:"
78
+ );
79
+ console.log("scrape-page-docusaurus");
80
+ console.log("scrape-page-gitbook");
81
+ console.log("scrape-page-readme");
82
+ return process.exit(1);
83
+ }
84
+ }
@@ -0,0 +1,8 @@
1
+ export default function alternateGroupTitle(firstLink, pages) {
2
+ // Only assign titles to nested navigation menus outside a section.
3
+ // Others should not have a title so we can merge them into one section.
4
+ if (pages.length > 0) {
5
+ return firstLink?.text();
6
+ }
7
+ return "";
8
+ }
@@ -1,4 +1,4 @@
1
- // Used by GitBook and ReadMe section scrapers
1
+ // Used by Docusaurus, GitBook, and ReadMe section scrapers
2
2
  export default function getLinksRecursively(linkSections: any, $: any) {
3
3
  if (linkSections == null || linkSections.length === 0) {
4
4
  return [];
@@ -7,8 +7,12 @@ export default function getLinksRecursively(linkSections: any, $: any) {
7
7
  return linkSections
8
8
  .map((i, s) => {
9
9
  const subsection = $(s);
10
- const link = subsection.children().first();
10
+ let link = subsection.children().first();
11
11
 
12
+ if (!link.attr("href")) {
13
+ // Docusaurus nests the <a> inside a <div>
14
+ link = link.find("a[href]").first();
15
+ }
12
16
  const linkHref = link.attr("href");
13
17
 
14
18
  // Skip missing links. For example, GitBook uses
@@ -16,6 +20,7 @@ export default function getLinksRecursively(linkSections: any, $: any) {
16
20
  // Skip external links until Mintlify supports them
17
21
  if (
18
22
  !linkHref ||
23
+ linkHref === "#" ||
19
24
  linkHref.startsWith("https://") ||
20
25
  linkHref.startsWith("http://")
21
26
  ) {
@@ -0,0 +1,42 @@
1
+ import { Page } from "puppeteer";
2
+
3
+ export default async function openNestedDocusaurusMenus(page: Page) {
4
+ let prevEncountered: string[] = [];
5
+ let encounteredHref = ["fake-href-to-make-loop-run-at-least-once"];
6
+
7
+ // Loop until we've encountered every link
8
+ while (!encounteredHref.every((href) => prevEncountered.includes(href))) {
9
+ prevEncountered = encounteredHref;
10
+ encounteredHref = await page.evaluate(
11
+ (encounteredHref) => {
12
+ const collapsible: HTMLElement[] = Array.from(
13
+ document.querySelectorAll(".menu__link.menu__link--sublist")
14
+ );
15
+
16
+ const linksFound: string[] = [];
17
+ collapsible.forEach(async (collapsibleItem: HTMLElement) => {
18
+ const href = collapsibleItem?.getAttribute("href");
19
+
20
+ // Should never occur but we keep it as a fail-safe
21
+ if (href?.startsWith("https://") || href?.startsWith("http://")) {
22
+ return;
23
+ }
24
+
25
+ // Click any links we haven't seen before
26
+ if (href && !encounteredHref.includes(href)) {
27
+ collapsibleItem?.click();
28
+ }
29
+
30
+ if (href) {
31
+ linksFound.push(href);
32
+ }
33
+ });
34
+
35
+ return linksFound;
36
+ },
37
+ encounteredHref // Need to pass array into the browser
38
+ );
39
+ }
40
+
41
+ return await page.content();
42
+ }
@@ -0,0 +1,49 @@
1
+ import { Page } from "puppeteer";
2
+
3
+ export default async function openNestedGitbookMenus(page: Page) {
4
+ let prevEncountered: string[] = [];
5
+ let encounteredHref = ["fake-href-to-make-loop-run-at-least-once"];
6
+
7
+ // Loop until we've encountered every link
8
+ while (!encounteredHref.every((href) => prevEncountered.includes(href))) {
9
+ prevEncountered = encounteredHref;
10
+ encounteredHref = await page.evaluate(
11
+ (encounteredHref) => {
12
+ const icons: HTMLElement[] = Array.from(
13
+ document.querySelectorAll('path[d="M9 18l6-6-6-6"]')
14
+ );
15
+
16
+ const linksFound: string[] = [];
17
+ icons.forEach(async (icon: HTMLElement) => {
18
+ const toClick = icon?.parentElement?.parentElement;
19
+ const link = toClick?.parentElement?.parentElement;
20
+
21
+ // Skip icons not in the side navigation
22
+ if (!link?.hasAttribute("href")) {
23
+ return;
24
+ }
25
+
26
+ const href = link.getAttribute("href");
27
+
28
+ // Should never occur but we keep it as a fail-safe
29
+ if (href?.startsWith("https://") || href?.startsWith("http://")) {
30
+ return;
31
+ }
32
+
33
+ // Click any links we haven't seen before
34
+ if (href && !encounteredHref.includes(href)) {
35
+ toClick?.click();
36
+ }
37
+ if (href) {
38
+ linksFound.push(href);
39
+ }
40
+ });
41
+
42
+ return linksFound;
43
+ },
44
+ encounteredHref // Need to pass array into the browser
45
+ );
46
+ }
47
+
48
+ return await page.content();
49
+ }
@@ -1,6 +1,10 @@
1
1
  import cheerio from "cheerio";
2
+ import { NavigationEntry } from "../..//navigation.js";
2
3
  import { scrapeGettingFileNameFromUrl } from "../scrapeGettingFileNameFromUrl.js";
4
+ import combineNavWithEmptyGroupTitles from "../combineNavWithEmptyGroupTitles.js";
3
5
  import { scrapeDocusaurusPage } from "./scrapeDocusaurusPage.js";
6
+ import getLinksRecursively from "./getLinksRecursively.js";
7
+ import alternateGroupTitle from "./alternateGroupTitle.js";
4
8
 
5
9
  export async function scrapeDocusaurusSection(
6
10
  html: string,
@@ -15,51 +19,49 @@ export async function scrapeDocusaurusSection(
15
19
 
16
20
  // Get all links per group
17
21
  const groupsConfig = navigationSections
18
- .map((i, section) => {
19
- const sectionComponent = $(section);
22
+ .map((i, s) => {
23
+ const section = $(s);
20
24
 
21
25
  // Links without a group
22
- if (sectionComponent.hasClass("theme-doc-sidebar-item-link")) {
23
- const linkHref = sectionComponent.find("a[href]").first().attr("href");
26
+ if (section.hasClass("theme-doc-sidebar-item-link")) {
27
+ const linkHref = section.find("a[href]").first().attr("href");
24
28
  return {
25
29
  group: "",
26
30
  pages: [linkHref],
27
31
  };
28
32
  }
29
33
 
30
- const sectionTitle = sectionComponent
34
+ const firstLink = section
31
35
  .find(".menu__list-item-collapsible")
32
36
  .first()
33
- .text();
37
+ .find("a[href]");
34
38
 
35
- // The category title can be a page too so we find from the
36
- // section component instead of the more specific menu__list child
37
- const linkPaths = sectionComponent
38
- .find("a[href]")
39
- .map((i, link) => {
40
- return $(link).attr("href");
41
- })
42
- .filter((i, link) => link !== "#")
43
- .toArray();
39
+ const sectionTitle = firstLink.text();
40
+ const firstHref = firstLink.attr("href");
41
+ const linkSections = section.children().eq(1).children();
42
+
43
+ const pages = getLinksRecursively(linkSections, $);
44
44
 
45
- // Follows the same structure as mint.json
46
45
  return {
47
- group: sectionTitle,
48
- pages: linkPaths,
46
+ group: sectionTitle || alternateGroupTitle(firstLink, pages),
47
+ pages: firstHref ? [firstHref, ...pages] : pages,
49
48
  };
50
49
  })
51
50
  .toArray();
52
51
 
52
+ // Merge groups with empty titles together
53
+ const reducedGroupsConfig = combineNavWithEmptyGroupTitles(groupsConfig);
54
+
53
55
  // Scrape each link in the navigation.
54
56
  const groupsConfigCleanPaths = await Promise.all(
55
- groupsConfig.map(async (groupConfig) => {
57
+ reducedGroupsConfig.map(async (groupConfig) => {
56
58
  groupConfig.pages = (
57
59
  await Promise.all(
58
- groupConfig.pages.map(async (pathname: string) =>
60
+ groupConfig.pages.map(async (navEntry: NavigationEntry) =>
59
61
  // Docusaurus requires a directory on all sections wheras we use root.
60
62
  // /docs is their default directory so we remove it
61
63
  scrapeGettingFileNameFromUrl(
62
- pathname,
64
+ navEntry,
63
65
  cliDir,
64
66
  origin,
65
67
  overwrite,
@@ -4,6 +4,7 @@ import { scrapeGettingFileNameFromUrl } from "../scrapeGettingFileNameFromUrl.js
4
4
  import { scrapeGitBookPage } from "./scrapeGitBookPage.js";
5
5
  import combineNavWithEmptyGroupTitles from "../combineNavWithEmptyGroupTitles.js";
6
6
  import getLinksRecursively from "./getLinksRecursively.js";
7
+ import alternateGroupTitle from "./alternateGroupTitle.js";
7
8
 
8
9
  export async function scrapeGitBookSection(
9
10
  html: string,
@@ -40,7 +41,7 @@ export async function scrapeGitBookSection(
40
41
  const pages = getLinksRecursively(linkSections, $);
41
42
 
42
43
  return {
43
- group: sectionTitle || alternateTitle(firstLink, pages),
44
+ group: sectionTitle || alternateGroupTitle(firstLink, pages),
44
45
  pages: firstHref ? [firstHref, ...pages] : pages,
45
46
  };
46
47
  })
@@ -66,12 +67,3 @@ export async function scrapeGitBookSection(
66
67
 
67
68
  return groupsConfigCleanPaths;
68
69
  }
69
-
70
- function alternateTitle(firstLink, pages) {
71
- // Only assign titles to nested navigation menus outside a section.
72
- // Others should not have a title so we can merge them into one section.
73
- if (pages.length > 0) {
74
- return firstLink?.text();
75
- }
76
- return "";
77
- }
@@ -1,8 +0,0 @@
1
- import shell from "shelljs";
2
- import { CLIENT_PATH } from "../../constants.js";
3
- const cleanCommand = () => {
4
- shell.cd(CLIENT_PATH);
5
- shell.exec("git clean -d -x -e node_modules -n");
6
- };
7
- export default cleanCommand;
8
- //# sourceMappingURL=cleanCommand.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cleanCommand.js","sourceRoot":"","sources":["../../../src/local-preview/helper-commands/cleanCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IACtB,KAAK,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}