@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.
- package/bin/cli.js +1 -0
- package/bin/cli.js.map +1 -1
- package/bin/components/Callout.js +0 -3
- package/bin/components/Callout.js.map +1 -1
- package/bin/components/Card.js +1 -5
- package/bin/components/Card.js.map +1 -1
- package/bin/components/CardGroup.js +1 -1
- package/bin/components/CardGroup.js.map +1 -1
- package/bin/components/CodeGroup.js +1 -3
- package/bin/components/CodeGroup.js.map +1 -1
- package/bin/components/Tabs.js +1 -2
- package/bin/components/Tabs.js.map +1 -1
- package/bin/constants.js +1 -0
- package/bin/constants.js.map +1 -1
- package/bin/nav/root.js +4 -16
- package/bin/nav/root.js.map +1 -1
- package/bin/pipeline/icon.js +4 -4
- package/bin/pipeline/icon.js.map +1 -1
- package/bin/pipeline/logo.js +18 -16
- package/bin/pipeline/logo.js.map +1 -1
- package/bin/pipeline/page.js +3 -1
- package/bin/pipeline/page.js.map +1 -1
- package/bin/root/retrieve.js +16 -29
- package/bin/root/retrieve.js.map +1 -1
- package/bin/tabs/retrieve.js +0 -3
- package/bin/tabs/retrieve.js.map +1 -1
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/bin/utils/breadcrumbs.js +0 -1
- package/bin/utils/breadcrumbs.js.map +1 -1
- package/bin/utils/intersection.d.ts +1 -0
- package/bin/utils/intersection.js +13 -0
- package/bin/utils/intersection.js.map +1 -0
- package/bin/utils/path.js +3 -8
- package/bin/utils/path.js.map +1 -1
- package/bin/utils/toc.js +0 -1
- package/bin/utils/toc.js.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +1 -0
- package/src/components/Callout.ts +0 -3
- package/src/components/Card.ts +0 -4
- package/src/components/CardGroup.ts +1 -1
- package/src/components/CodeGroup.ts +1 -3
- package/src/components/Tabs.ts +1 -2
- package/src/constants.ts +1 -0
- package/src/nav/root.ts +4 -16
- package/src/pipeline/icon.ts +4 -3
- package/src/pipeline/logo.ts +20 -24
- package/src/pipeline/page.ts +2 -1
- package/src/root/retrieve.ts +17 -31
- package/src/tabs/retrieve.ts +0 -3
- package/src/utils/breadcrumbs.ts +0 -1
- package/src/utils/intersection.ts +11 -0
- package/src/utils/path.ts +3 -7
- package/src/utils/toc.ts +0 -1
package/bin/utils/breadcrumbs.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
14
|
-
filename
|
|
12
|
+
if (filename.endsWith('/')) {
|
|
13
|
+
filename += 'index';
|
|
15
14
|
}
|
|
16
|
-
|
|
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
|
package/bin/utils/path.js.map
CHANGED
|
@@ -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;
|
|
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 &&
|
package/bin/utils/toc.js.map
CHANGED
|
@@ -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,
|
|
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.
|
|
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.
|
|
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.
|
|
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": "
|
|
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'))
|
package/src/components/Card.ts
CHANGED
|
@@ -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'
|
|
196
|
+
if ((node.tagName !== 'div' && node.tagName !== 'ul') || node.properties.role !== 'tablist') {
|
|
199
197
|
return undefined;
|
|
200
198
|
}
|
|
201
199
|
|
package/src/components/Tabs.ts
CHANGED
|
@@ -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'
|
|
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
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
|
-
}
|
package/src/pipeline/icon.ts
CHANGED
|
@@ -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 ===
|
|
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
|
}
|
package/src/pipeline/logo.ts
CHANGED
|
@@ -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
|
-
|
|
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);
|
package/src/pipeline/page.ts
CHANGED
|
@@ -57,7 +57,8 @@ export async function scrapePage(
|
|
|
57
57
|
url = new URL(url);
|
|
58
58
|
|
|
59
59
|
if (opts.externalLink) {
|
|
60
|
-
|
|
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] };
|
package/src/root/retrieve.ts
CHANGED
|
@@ -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
|
|
7
|
+
let rootSelector: Map<string, string | undefined> = new Map([['main', 'break-anywhere']]);
|
|
8
8
|
switch (framework.vendor) {
|
|
9
9
|
case 'docusaurus':
|
|
10
|
-
|
|
10
|
+
rootSelector = new Map([
|
|
11
|
+
['article', undefined],
|
|
12
|
+
['div', 'index-page'],
|
|
13
|
+
]);
|
|
11
14
|
break;
|
|
12
15
|
case 'gitbook':
|
|
13
|
-
|
|
16
|
+
rootSelector = new Map([['main', undefined]]);
|
|
14
17
|
break;
|
|
15
18
|
case 'readme':
|
|
16
|
-
|
|
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
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
package/src/tabs/retrieve.ts
CHANGED
|
@@ -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
|
)
|
package/src/utils/breadcrumbs.ts
CHANGED
|
@@ -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
|
-
|
|
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 &&
|