@mintlify/scraping 4.0.439 → 4.0.441

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 (54) hide show
  1. package/bin/cli.js +1 -0
  2. package/bin/cli.js.map +1 -1
  3. package/bin/components/Callout.js +0 -3
  4. package/bin/components/Callout.js.map +1 -1
  5. package/bin/components/Card.js +1 -5
  6. package/bin/components/Card.js.map +1 -1
  7. package/bin/components/CardGroup.js +1 -1
  8. package/bin/components/CardGroup.js.map +1 -1
  9. package/bin/components/CodeGroup.js +1 -3
  10. package/bin/components/CodeGroup.js.map +1 -1
  11. package/bin/components/Tabs.js +1 -2
  12. package/bin/components/Tabs.js.map +1 -1
  13. package/bin/constants.js +1 -0
  14. package/bin/constants.js.map +1 -1
  15. package/bin/nav/root.js +4 -16
  16. package/bin/nav/root.js.map +1 -1
  17. package/bin/pipeline/icon.js +4 -4
  18. package/bin/pipeline/icon.js.map +1 -1
  19. package/bin/pipeline/logo.js +18 -16
  20. package/bin/pipeline/logo.js.map +1 -1
  21. package/bin/pipeline/page.js +3 -1
  22. package/bin/pipeline/page.js.map +1 -1
  23. package/bin/root/retrieve.js +16 -29
  24. package/bin/root/retrieve.js.map +1 -1
  25. package/bin/tabs/retrieve.js +0 -3
  26. package/bin/tabs/retrieve.js.map +1 -1
  27. package/bin/tsconfig.build.tsbuildinfo +1 -1
  28. package/bin/utils/breadcrumbs.js +0 -1
  29. package/bin/utils/breadcrumbs.js.map +1 -1
  30. package/bin/utils/intersection.d.ts +1 -0
  31. package/bin/utils/intersection.js +13 -0
  32. package/bin/utils/intersection.js.map +1 -0
  33. package/bin/utils/path.js +3 -8
  34. package/bin/utils/path.js.map +1 -1
  35. package/bin/utils/toc.js +0 -1
  36. package/bin/utils/toc.js.map +1 -1
  37. package/package.json +4 -4
  38. package/src/cli.ts +1 -0
  39. package/src/components/Callout.ts +0 -3
  40. package/src/components/Card.ts +0 -4
  41. package/src/components/CardGroup.ts +1 -1
  42. package/src/components/CodeGroup.ts +1 -3
  43. package/src/components/Tabs.ts +1 -2
  44. package/src/constants.ts +1 -0
  45. package/src/nav/root.ts +4 -16
  46. package/src/pipeline/icon.ts +4 -3
  47. package/src/pipeline/logo.ts +20 -24
  48. package/src/pipeline/page.ts +2 -1
  49. package/src/root/retrieve.ts +17 -31
  50. package/src/tabs/retrieve.ts +0 -3
  51. package/src/utils/breadcrumbs.ts +0 -1
  52. package/src/utils/intersection.ts +11 -0
  53. package/src/utils/path.ts +3 -7
  54. package/src/utils/toc.ts +0 -1
@@ -14,7 +14,6 @@ export function removeBreadCrumbs(node) {
14
14
  return visit(node, 'element', function (subNode, index, parent) {
15
15
  if (framework.vendor === 'docusaurus' &&
16
16
  subNode.tagName === 'nav' &&
17
- subNode.properties.className &&
18
17
  Array.isArray(subNode.properties.className) &&
19
18
  subNode.properties.className.includes('theme-doc-breadcrumbs') &&
20
19
  parent &&
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../src/utils/breadcrumbs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,UAAU,wBAAwB;IACtC,OAAO,UAAU,IAAa;QAC5B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC7C,OAAO,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,OAAO,EAAE,KAAK,EAAE,MAAM;QAC5D,IACE,SAAS,CAAC,MAAM,KAAK,YAAY;YACjC,OAAO,CAAC,OAAO,KAAK,KAAK;YACzB,OAAO,CAAC,UAAU,CAAC,SAAS;YAC5B,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YAC3C,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,uBAAuB,CAAC;YAC9D,MAAM;YACN,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;YACD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../src/utils/breadcrumbs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,UAAU,wBAAwB;IACtC,OAAO,UAAU,IAAa;QAC5B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC7C,OAAO,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,OAAO,EAAE,KAAK,EAAE,MAAM;QAC5D,IACE,SAAS,CAAC,MAAM,KAAK,YAAY;YACjC,OAAO,CAAC,OAAO,KAAK,KAAK;YACzB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YAC3C,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,uBAAuB,CAAC;YAC9D,MAAM;YACN,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;YACD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function intersection<T>(set1: Set<T> | Array<T>, set2: Set<T> | Array<T>): Set<T>;
@@ -0,0 +1,13 @@
1
+ export function intersection(set1, set2) {
2
+ if (Array.isArray(set1))
3
+ set1 = new Set(set1);
4
+ if (Array.isArray(set2))
5
+ set2 = new Set(set2);
6
+ const intersectedSet = new Set();
7
+ for (const el of set1) {
8
+ if (set2.has(el))
9
+ intersectedSet.add(el);
10
+ }
11
+ return intersectedSet;
12
+ }
13
+ //# sourceMappingURL=intersection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intersection.js","sourceRoot":"","sources":["../../src/utils/intersection.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAI,IAAuB,EAAE,IAAuB;IAC9E,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAE9C,MAAM,cAAc,GAAG,IAAI,GAAG,EAAK,CAAC;IACpC,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
package/bin/utils/path.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { join } from 'path';
2
2
  import { addMdx } from './extension.js';
3
3
  import { toFilename } from './file.js';
4
- import { log } from './log.js';
5
4
  export function createFilename(rootPath = process.cwd(), filename, title) {
6
5
  if (typeof filename === 'string' && filename.startsWith('http')) {
7
6
  const url = new URL(filename);
@@ -10,13 +9,9 @@ export function createFilename(rootPath = process.cwd(), filename, title) {
10
9
  else if (typeof filename === 'object') {
11
10
  filename = filename.pathname;
12
11
  }
13
- else {
14
- filename = filename;
12
+ if (filename.endsWith('/')) {
13
+ filename += 'index';
15
14
  }
16
- if (filename === '') {
17
- log(`Invalid file name provided: ${filename}`, 'error');
18
- return undefined;
19
- }
20
- return join(rootPath, addMdx(filename || toFilename(title ?? '')));
15
+ return join(rootPath, addMdx(filename || toFilename(title || 'index')));
21
16
  }
22
17
  //# sourceMappingURL=path.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,UAAU,cAAc,CAC5B,WAAmB,OAAO,CAAC,GAAG,EAAE,EAChC,QAAsB,EACtB,KAAc;IAEd,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAChE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC1B,CAAC;SAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACxC,QAAQ,GAAI,QAAgB,CAAC,QAAQ,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,QAAkB,CAAC;IAChC,CAAC;IAED,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QACpB,GAAG,CAAC,+BAA+B,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC"}
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,UAAU,cAAc,CAC5B,WAAmB,OAAO,CAAC,GAAG,EAAE,EAChC,QAAsB,EACtB,KAAc;IAEd,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAChE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC1B,CAAC;SAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACxC,QAAQ,GAAI,QAAgB,CAAC,QAAQ,CAAC;IACxC,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,QAAQ,IAAI,OAAO,CAAC;IACtB,CAAC;IAED,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC"}
package/bin/utils/toc.js CHANGED
@@ -14,7 +14,6 @@ export function removeTableOfContents(node) {
14
14
  return visit(node, 'element', function (subNode, index, parent) {
15
15
  if (framework.vendor === 'docusaurus' &&
16
16
  subNode.tagName === 'div' &&
17
- subNode.properties.className &&
18
17
  Array.isArray(subNode.properties.className) &&
19
18
  subNode.properties.className.includes('theme-doc-toc-mobile') &&
20
19
  parent &&
@@ -1 +1 @@
1
- {"version":3,"file":"toc.js","sourceRoot":"","sources":["../../src/utils/toc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,UAAU,IAAa;QAC5B,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAa;IACjD,OAAO,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,OAAO,EAAE,KAAK,EAAE,MAAM;QAC5D,IACE,SAAS,CAAC,MAAM,KAAK,YAAY;YACjC,OAAO,CAAC,OAAO,KAAK,KAAK;YACzB,OAAO,CAAC,UAAU,CAAC,SAAS;YAC5B,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YAC3C,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,sBAAsB,CAAC;YAC7D,MAAM;YACN,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;YACD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"toc.js","sourceRoot":"","sources":["../../src/utils/toc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,UAAU,IAAa;QAC5B,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAa;IACjD,OAAO,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,OAAO,EAAE,KAAK,EAAE,MAAM;QAC5D,IACE,SAAS,CAAC,MAAM,KAAK,YAAY;YACjC,OAAO,CAAC,OAAO,KAAK,KAAK;YACzB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YAC3C,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,sBAAsB,CAAC;YAC7D,MAAM;YACN,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;YACD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/scraping",
3
- "version": "4.0.439",
3
+ "version": "4.0.441",
4
4
  "description": "Scrape documentation frameworks to Mintlify docs",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -38,7 +38,7 @@
38
38
  "format:check": "prettier . --check"
39
39
  },
40
40
  "dependencies": {
41
- "@mintlify/common": "1.0.580",
41
+ "@mintlify/common": "1.0.581",
42
42
  "@mintlify/openapi-parser": "^0.0.8",
43
43
  "fs-extra": "^11.1.1",
44
44
  "hast-util-to-mdast": "^10.1.0",
@@ -61,7 +61,7 @@
61
61
  "@mintlify/models": "0.0.235",
62
62
  "@mintlify/prettier-config": "1.0.4",
63
63
  "@mintlify/ts-config": "2.0.2",
64
- "@mintlify/validation": "0.1.504",
64
+ "@mintlify/validation": "0.1.505",
65
65
  "@trivago/prettier-plugin-sort-imports": "^4.2.1",
66
66
  "@tsconfig/recommended": "1.x",
67
67
  "@types/hast": "^3.0.4",
@@ -77,5 +77,5 @@
77
77
  "typescript": "^5.5.3",
78
78
  "vitest": "^2.0.4"
79
79
  },
80
- "gitHead": "d24a7506b0477ac367cc6b501035d9b159c105fc"
80
+ "gitHead": "58cf3c084aa0428be062febf942f1033623f1e71"
81
81
  }
package/src/cli.ts CHANGED
@@ -129,6 +129,7 @@ async function site(url: string) {
129
129
  const docsConfig = upgradeToDocsConfig(mintConfig, {
130
130
  shouldUpgradeTheme: true,
131
131
  });
132
+ docsConfig.theme = 'aspen';
132
133
  write('docs.json', JSON.stringify(docsConfig, undefined, 2));
133
134
  log(FINAL_SUCCESS_MESSAGE);
134
135
  } else {
@@ -11,7 +11,6 @@ export function gitBookScrapeCallout(
11
11
  ): Element | undefined {
12
12
  if (
13
13
  node.tagName !== 'div' ||
14
- !node.properties.className ||
15
14
  !Array.isArray(node.properties.className) ||
16
15
  !node.properties.className
17
16
  .join(' ')
@@ -63,7 +62,6 @@ export function readmeScrapeCallout(
63
62
  ): Element | undefined {
64
63
  if (
65
64
  node.tagName !== 'blockquote' ||
66
- !node.properties.className ||
67
65
  !Array.isArray(node.properties.className) ||
68
66
  !node.properties.className.includes('callout')
69
67
  ) {
@@ -113,7 +111,6 @@ export function docusaurusScrapeCallout(
113
111
  ): Element | undefined {
114
112
  if (
115
113
  node.tagName !== 'div' ||
116
- !node.properties.className ||
117
114
  !Array.isArray(node.properties.className) ||
118
115
  (!node.properties.className.includes('admonition') &&
119
116
  !node.properties.className.includes('theme-admonition'))
@@ -14,7 +14,6 @@ export function gitBookScrapeCard(
14
14
  ): Element | undefined {
15
15
  if (
16
16
  (node.tagName !== 'a' && node.tagName !== 'div') ||
17
- !node.properties.className ||
18
17
  !Array.isArray(node.properties.className) ||
19
18
  !node.properties.className
20
19
  .join(' ')
@@ -28,7 +27,6 @@ export function gitBookScrapeCard(
28
27
  let firstTextElement: Element | undefined = undefined;
29
28
  visit(node, 'element', function (subNode, index, parent) {
30
29
  if (
31
- !subNode.properties.className ||
32
30
  !Array.isArray(subNode.properties.className) ||
33
31
  subNode.properties.className.join(' ') !== 'w-full space-y-2 lg:space-y-3 leading-normal'
34
32
  )
@@ -66,7 +64,6 @@ export function readmeScrapeCard(
66
64
  ): Element | undefined {
67
65
  if (
68
66
  (node.tagName !== 'div' && node.tagName !== 'a') ||
69
- !node.properties.className ||
70
67
  !Array.isArray(node.properties.className) ||
71
68
  (!node.properties.className.includes('Tile') &&
72
69
  !node.properties.className.includes('card') &&
@@ -121,7 +118,6 @@ export function docusaurusScrapeCard(
121
118
  ): Element | undefined {
122
119
  if (
123
120
  (node.tagName !== 'div' && node.tagName !== 'a') ||
124
- !node.properties.className ||
125
121
  !Array.isArray(node.properties.className) ||
126
122
  (!node.properties.className.includes('Tile') &&
127
123
  !node.properties.className.includes('card') &&
@@ -57,7 +57,7 @@ export function docusaurusScrapeCardGroup(
57
57
  if (child.type === 'element' && child.tagName === 'Card') cardCount++;
58
58
  }
59
59
 
60
- if (cardCount === parent.children.length) {
60
+ if (cardCount === parent.children.length && cardCount > 1) {
61
61
  parent.type = 'element';
62
62
  (parent as Element).tagName = 'CardGroup';
63
63
  }
@@ -132,7 +132,6 @@ export function readmeScrapeCodeGroup(
132
132
  ): Element | undefined {
133
133
  if (
134
134
  node.tagName !== 'div' ||
135
- !node.properties.className ||
136
135
  !Array.isArray(node.properties.className) ||
137
136
  !node.properties.className.includes('CodeTabs')
138
137
  ) {
@@ -143,7 +142,6 @@ export function readmeScrapeCodeGroup(
143
142
  visit(node, 'element', function (node) {
144
143
  if (
145
144
  node.tagName !== 'div' ||
146
- !node.properties.className ||
147
145
  !Array.isArray(node.properties.className) ||
148
146
  !node.properties.className.includes('CodeTabs-inner')
149
147
  ) {
@@ -195,7 +193,7 @@ export function docusaurusScrapeCodeGroup(
195
193
  _: HastNodeIndex,
196
194
  parent: HastNodeParent
197
195
  ): Element | undefined {
198
- if (node.tagName !== 'div' || !node.properties.role || node.properties.role !== 'tablist') {
196
+ if ((node.tagName !== 'div' && node.tagName !== 'ul') || node.properties.role !== 'tablist') {
199
197
  return undefined;
200
198
  }
201
199
 
@@ -59,7 +59,6 @@ export function readmeScrapeTabs(
59
59
  ): Element | undefined {
60
60
  if (
61
61
  (node.tagName !== 'div' && node.tagName !== 'a') ||
62
- !node.properties.className ||
63
62
  !Array.isArray(node.properties.className) ||
64
63
  (!node.properties.className.includes('tabbed-component') &&
65
64
  !node.properties.className.includes('tabs') &&
@@ -144,7 +143,7 @@ export function docusaurusScrapeTabs(
144
143
  _: HastNodeIndex,
145
144
  parent: HastNodeParent
146
145
  ): Element | undefined {
147
- if (node.tagName !== 'div' || !node.properties.role || node.properties.role !== 'tablist') {
146
+ if ((node.tagName !== 'div' && node.tagName !== 'ul') || node.properties.role !== 'tablist') {
148
147
  return undefined;
149
148
  }
150
149
 
package/src/constants.ts CHANGED
@@ -15,6 +15,7 @@ export const SUPPORTED_MEDIA_EXTENSIONS = [
15
15
  'pjp',
16
16
  'svgz',
17
17
  'bmp',
18
+ 'gif',
18
19
  ];
19
20
 
20
21
  export const ESCAPED_COMPONENTS = [
package/src/nav/root.ts CHANGED
@@ -2,6 +2,7 @@ import type { Root as HastRoot, Element } from 'hast';
2
2
  import { visit, EXIT } from 'unist-util-visit';
3
3
 
4
4
  import { framework } from '../utils/detectFramework.js';
5
+ import { intersection } from '../utils/intersection.js';
5
6
 
6
7
  export function retrieveRootNavElement(rootNode: HastRoot): Element | undefined {
7
8
  let rootTagName = 'aside';
@@ -17,10 +18,10 @@ export function retrieveRootNavElement(rootNode: HastRoot): Element | undefined
17
18
  break;
18
19
  }
19
20
 
20
- let rootSelectorSet = new Set('page-no-toc:hidden');
21
+ let rootSelectorSet = new Set(['page-no-toc:hidden']);
21
22
  switch (framework.vendor) {
22
23
  case 'docusaurus':
23
- rootSelectorSet = new Set('menu');
24
+ rootSelectorSet = new Set(['menu']);
24
25
  break;
25
26
  case 'gitbook':
26
27
  rootSelectorSet = new Set([
@@ -30,7 +31,7 @@ export function retrieveRootNavElement(rootNode: HastRoot): Element | undefined
30
31
  ]);
31
32
  break;
32
33
  case 'readme':
33
- rootSelectorSet = new Set('rm-Sidebar');
34
+ rootSelectorSet = new Set(['rm-Sidebar']);
34
35
  break;
35
36
  }
36
37
 
@@ -39,7 +40,6 @@ export function retrieveRootNavElement(rootNode: HastRoot): Element | undefined
39
40
  const { className } = node.properties;
40
41
  if (
41
42
  node.tagName === rootTagName &&
42
- className &&
43
43
  Array.isArray(className) &&
44
44
  !!intersection(className, rootSelectorSet).size
45
45
  ) {
@@ -50,15 +50,3 @@ export function retrieveRootNavElement(rootNode: HastRoot): Element | undefined
50
50
 
51
51
  return element;
52
52
  }
53
-
54
- function intersection<T>(set1: Set<T> | Array<T>, set2: Set<T> | Array<T>): Set<T> {
55
- if (Array.isArray(set1)) set1 = new Set(set1);
56
- if (Array.isArray(set2)) set2 = new Set(set2);
57
-
58
- const intersectedSet = new Set<T>();
59
- for (const el of set1) {
60
- if (set2.has(el)) intersectedSet.add(el);
61
- }
62
-
63
- return intersectedSet;
64
- }
@@ -1,13 +1,15 @@
1
1
  import type { Root as HastRoot } from 'hast';
2
2
  import { EXIT, visit } from 'unist-util-visit';
3
3
 
4
+ import { framework } from '../utils/detectFramework.js';
4
5
  import { downloadImage } from '../utils/images.js';
5
6
 
6
7
  export async function downloadFavicon(hast: HastRoot): Promise<string> {
7
8
  let src: string = '';
9
+ const tagName = framework.vendor === 'docusaurus' ? 'meta' : 'link';
8
10
  visit(hast, 'element', function (node) {
9
11
  if (
10
- node.tagName === 'link' &&
12
+ node.tagName === tagName &&
11
13
  Array.isArray(node.properties.rel) &&
12
14
  node.properties.rel.includes('icon')
13
15
  ) {
@@ -21,8 +23,7 @@ export async function downloadFavicon(hast: HastRoot): Promise<string> {
21
23
  }
22
24
 
23
25
  const res = await downloadImage(src, process.cwd());
24
- if (!res.success) return '/favicon.svg';
25
- if (!res.data) return '/favicon.svg';
26
+ if (!res.success || !res.data) return '/favicon.svg';
26
27
 
27
28
  return res.data[1];
28
29
  }
@@ -37,7 +37,6 @@ function findDocusaurusLogoNodes(root: HastRoot): Array<Element> | undefined {
37
37
  const elements: Array<Element> = [];
38
38
  visit(root, 'element', function (node) {
39
39
  if (
40
- node.tagName === 'div' &&
41
40
  Array.isArray(node.properties.className) &&
42
41
  node.properties.className.includes('navbar__brand')
43
42
  ) {
@@ -53,30 +52,26 @@ function findDocusaurusLogoNodes(root: HastRoot): Array<Element> | undefined {
53
52
  async function findLogosFromHtml(
54
53
  html: string,
55
54
  downloadFn: (root: HastRoot) => Array<Element> | undefined,
56
- filepaths: Array<string>
57
- ) {
55
+ filepaths: Array<string>,
56
+ url: URL
57
+ ): Promise<void> {
58
58
  const hast = htmlToHast(html);
59
59
  const imgNodes = downloadFn(hast);
60
+ if (!imgNodes) return;
61
+ const imagePaths = await Promise.all(
62
+ imgNodes.map(async (node) => {
63
+ const src = node.properties.src as string;
64
+ const imageUrl = new URL(src, url.origin).toString();
65
+ const res = await downloadImage(imageUrl, join(process.cwd(), 'images'));
66
+ if (res.success && res.data) {
67
+ return res.data[1];
68
+ } else {
69
+ return '';
70
+ }
71
+ })
72
+ );
60
73
 
61
- if (imgNodes) {
62
- filepaths.push(
63
- ...(await Promise.all(
64
- imgNodes.map(async (node) => {
65
- const res = await downloadImage(
66
- node.properties.src as string,
67
- join(process.cwd(), 'images')
68
- );
69
-
70
- if (res.success && res.data) {
71
- return res.data[1];
72
- } else {
73
- return '';
74
- }
75
- })
76
- ))
77
- );
78
- }
79
-
74
+ filepaths.push(...imagePaths.filter(Boolean));
80
75
  filepaths.forEach((filepath, index) => {
81
76
  if (!filepath) filepaths.splice(index, 1);
82
77
  });
@@ -105,7 +100,7 @@ export async function downloadLogos(
105
100
 
106
101
  await Promise.all(
107
102
  htmls.map(async (html) => {
108
- return await findLogosFromHtml(html, findReadmeLogoNodes, filepaths);
103
+ return await findLogosFromHtml(html, findReadmeLogoNodes, filepaths, url);
109
104
  })
110
105
  );
111
106
  } else {
@@ -114,7 +109,8 @@ export async function downloadLogos(
114
109
  await findLogosFromHtml(
115
110
  html,
116
111
  framework.vendor === 'gitbook' ? findGitBookLogoNodes : findDocusaurusLogoNodes,
117
- filepaths
112
+ filepaths,
113
+ url
118
114
  );
119
115
  } catch (error) {
120
116
  const errorMessage = getErrorMessage(error);
@@ -57,7 +57,8 @@ export async function scrapePage(
57
57
  url = new URL(url);
58
58
 
59
59
  if (opts.externalLink) {
60
- const filename = html;
60
+ let filename = html || 'index';
61
+ if (filename.endsWith('/')) filename += 'index';
61
62
  const filenameWithExt = `${filename}.mdx`;
62
63
  writePage(filenameWithExt, '', '', '', url.toString());
63
64
  return { success: true, data: [url.toString(), filename] };
@@ -1,50 +1,36 @@
1
1
  import type { Root as HastRoot, Element } from 'hast';
2
- import { visit, EXIT } from 'unist-util-visit';
2
+ import { visit, EXIT, CONTINUE } from 'unist-util-visit';
3
3
 
4
4
  import { framework } from '../utils/detectFramework.js';
5
5
 
6
6
  export function retrieveRootContent(rootNode: HastRoot): Element | undefined {
7
- let rootTagName = 'main';
7
+ let rootSelector: Map<string, string | undefined> = new Map([['main', 'break-anywhere']]);
8
8
  switch (framework.vendor) {
9
9
  case 'docusaurus':
10
- rootTagName = 'article';
10
+ rootSelector = new Map([
11
+ ['article', undefined],
12
+ ['div', 'index-page'],
13
+ ]);
11
14
  break;
12
15
  case 'gitbook':
13
- rootTagName = 'main';
16
+ rootSelector = new Map([['main', undefined]]);
14
17
  break;
15
18
  case 'readme':
16
- rootTagName = 'article';
17
- break;
18
- }
19
-
20
- let rootSelector = 'break-anywhere';
21
- switch (framework.vendor) {
22
- case 'docusaurus':
23
- rootSelector = '';
24
- break;
25
- case 'gitbook':
26
- rootSelector = '';
27
- break;
28
- case 'readme':
29
- rootSelector = 'rm-Article';
19
+ rootSelector = new Map([['article', 'rm-Article']]);
30
20
  break;
31
21
  }
32
22
 
33
23
  let element: Element | undefined = undefined;
34
24
  visit(rootNode, 'element', function (node) {
35
- if (node.tagName === rootTagName) {
36
- if (rootSelector) {
37
- if (
38
- node.properties.className &&
39
- Array.isArray(node.properties.className) &&
40
- node.properties.className.includes(rootSelector)
41
- ) {
42
- element = node;
43
- }
44
- } else {
45
- element = node;
46
- return EXIT;
47
- }
25
+ if (!rootSelector.has(node.tagName)) {
26
+ return CONTINUE;
27
+ }
28
+
29
+ const classNameSelector = rootSelector.get(node.tagName);
30
+ const { className } = node.properties;
31
+ if (!classNameSelector || (Array.isArray(className) && className.includes(classNameSelector))) {
32
+ element = node;
33
+ return EXIT;
48
34
  }
49
35
  });
50
36
 
@@ -19,7 +19,6 @@ export function retrieveTabLinks(rootNode: HastRoot, url: URL): Array<Tab> | und
19
19
  if (framework.vendor === 'readme') {
20
20
  if (
21
21
  node.tagName === 'header' &&
22
- node.properties.className &&
23
22
  Array.isArray(node.properties.className) &&
24
23
  node.properties.className.includes('rm-Header')
25
24
  ) {
@@ -31,7 +30,6 @@ export function retrieveTabLinks(rootNode: HastRoot, url: URL): Array<Tab> | und
31
30
  if (framework.vendor === 'docusaurus') {
32
31
  if (
33
32
  node.tagName === 'nav' &&
34
- node.properties.className &&
35
33
  Array.isArray(node.properties.className) &&
36
34
  node.properties.className.includes('navbar')
37
35
  ) {
@@ -62,7 +60,6 @@ export function retrieveTabLinks(rootNode: HastRoot, url: URL): Array<Tab> | und
62
60
  node.tagName !== 'nav' &&
63
61
  !(
64
62
  node.tagName === 'div' &&
65
- node.properties.className &&
66
63
  Array.isArray(node.properties.className) &&
67
64
  node.properties.className.includes('rm-Header-right')
68
65
  )
@@ -19,7 +19,6 @@ export function removeBreadCrumbs(node: Element) {
19
19
  if (
20
20
  framework.vendor === 'docusaurus' &&
21
21
  subNode.tagName === 'nav' &&
22
- subNode.properties.className &&
23
22
  Array.isArray(subNode.properties.className) &&
24
23
  subNode.properties.className.includes('theme-doc-breadcrumbs') &&
25
24
  parent &&
@@ -0,0 +1,11 @@
1
+ export function intersection<T>(set1: Set<T> | Array<T>, set2: Set<T> | Array<T>): Set<T> {
2
+ if (Array.isArray(set1)) set1 = new Set(set1);
3
+ if (Array.isArray(set2)) set2 = new Set(set2);
4
+
5
+ const intersectedSet = new Set<T>();
6
+ for (const el of set1) {
7
+ if (set2.has(el)) intersectedSet.add(el);
8
+ }
9
+
10
+ return intersectedSet;
11
+ }
package/src/utils/path.ts CHANGED
@@ -2,7 +2,6 @@ import { join } from 'path';
2
2
 
3
3
  import { addMdx } from './extension.js';
4
4
  import { toFilename } from './file.js';
5
- import { log } from './log.js';
6
5
 
7
6
  export function createFilename(
8
7
  rootPath: string = process.cwd(),
@@ -14,14 +13,11 @@ export function createFilename(
14
13
  filename = url.pathname;
15
14
  } else if (typeof filename === 'object') {
16
15
  filename = (filename as URL).pathname;
17
- } else {
18
- filename = filename as string;
19
16
  }
20
17
 
21
- if (filename === '') {
22
- log(`Invalid file name provided: ${filename}`, 'error');
23
- return undefined;
18
+ if (filename.endsWith('/')) {
19
+ filename += 'index';
24
20
  }
25
21
 
26
- return join(rootPath, addMdx(filename || toFilename(title ?? '')));
22
+ return join(rootPath, addMdx(filename || toFilename(title || 'index')));
27
23
  }
package/src/utils/toc.ts CHANGED
@@ -19,7 +19,6 @@ export function removeTableOfContents(node: Element) {
19
19
  if (
20
20
  framework.vendor === 'docusaurus' &&
21
21
  subNode.tagName === 'div' &&
22
- subNode.properties.className &&
23
22
  Array.isArray(subNode.properties.className) &&
24
23
  subNode.properties.className.includes('theme-doc-toc-mobile') &&
25
24
  parent &&