@docusaurus/utils 3.8.1-canary-6386 → 3.8.1-canary-6389
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/lib/markdownLinks.d.ts.map +1 -1
- package/lib/markdownLinks.js +30 -13
- package/lib/markdownLinks.js.map +1 -1
- package/package.json +5 -5
- package/src/markdownLinks.ts +35 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownLinks.d.ts","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,IAAI;IACvD,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,GAAG,CACjC,MAAM,EAAE,gDAAgD;AACxD,MAAM,CACP,CAAC;
|
|
1
|
+
{"version":3,"file":"markdownLinks.d.ts","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,IAAI;IACvD,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,GAAG,CACjC,MAAM,EAAE,gDAAgD;AACxD,MAAM,CACP,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE;IACP,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,GACA,MAAM,GAAG,IAAI,CA6Cf"}
|
package/lib/markdownLinks.js
CHANGED
|
@@ -11,24 +11,41 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const dataFileUtils_1 = require("./dataFileUtils");
|
|
13
13
|
const pathUtils_1 = require("./pathUtils");
|
|
14
|
-
// Note this is historical logic extracted during a 2024 refactor
|
|
15
|
-
// The algo has been kept exactly as before for retro compatibility
|
|
16
|
-
// See also https://github.com/facebook/docusaurus/pull/10168
|
|
17
14
|
function resolveMarkdownLinkPathname(linkPathname, context) {
|
|
18
15
|
const { sourceFilePath, sourceToPermalink, contentPaths, siteDir } = context;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
sourceDirsToTry.push(...(0, dataFileUtils_1.getContentPathList)(contentPaths), siteDir);
|
|
16
|
+
// If the link is already @site aliased, there's no need to resolve it
|
|
17
|
+
if (linkPathname.startsWith('@site/')) {
|
|
18
|
+
return sourceToPermalink.get(decodeURIComponent(linkPathname)) ?? null;
|
|
23
19
|
}
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
// Get the dirs to "look into", ordered by priority, when resolving the link
|
|
21
|
+
function getSourceDirsToTry() {
|
|
22
|
+
// /file.md is always resolved from
|
|
23
|
+
// - the plugin content paths,
|
|
24
|
+
// - then siteDir
|
|
25
|
+
if (linkPathname.startsWith('/')) {
|
|
26
|
+
return [...(0, dataFileUtils_1.getContentPathList)(contentPaths), siteDir];
|
|
27
|
+
}
|
|
28
|
+
// ./file.md and ../file.md are always resolved from
|
|
29
|
+
// - the current file dir
|
|
30
|
+
else if (linkPathname.startsWith('./') || linkPathname.startsWith('../')) {
|
|
31
|
+
return [path_1.default.dirname(sourceFilePath)];
|
|
32
|
+
}
|
|
33
|
+
// file.md is resolved from
|
|
34
|
+
// - the current file dir,
|
|
35
|
+
// - then from the plugin content paths,
|
|
36
|
+
// - then siteDir
|
|
37
|
+
else {
|
|
38
|
+
return [
|
|
39
|
+
path_1.default.dirname(sourceFilePath),
|
|
40
|
+
...(0, dataFileUtils_1.getContentPathList)(contentPaths),
|
|
41
|
+
siteDir,
|
|
42
|
+
];
|
|
43
|
+
}
|
|
27
44
|
}
|
|
28
|
-
const
|
|
45
|
+
const sourcesToTry = getSourceDirsToTry()
|
|
29
46
|
.map((sourceDir) => path_1.default.join(sourceDir, decodeURIComponent(linkPathname)))
|
|
30
|
-
.map((source) => (0, pathUtils_1.aliasedSitePath)(source, siteDir))
|
|
31
|
-
|
|
47
|
+
.map((source) => (0, pathUtils_1.aliasedSitePath)(source, siteDir));
|
|
48
|
+
const aliasedSourceMatch = sourcesToTry.find((source) => sourceToPermalink.has(source));
|
|
32
49
|
return aliasedSourceMatch
|
|
33
50
|
? sourceToPermalink.get(aliasedSourceMatch) ?? null
|
|
34
51
|
: null;
|
package/lib/markdownLinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownLinks.js","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"markdownLinks.js","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA4CH,kEAqDC;;AA/FD,wDAAwB;AACxB,mDAAmD;AACnD,2CAA4C;AAwC5C,SAAgB,2BAA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AkB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACtD,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAC9B,CAAC;IAEF,OAAO,kBAAkB;QACvB,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,IAAI;QACnD,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "3.8.1-canary-
|
|
3
|
+
"version": "3.8.1-canary-6389",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "3.8.1-canary-
|
|
22
|
-
"@docusaurus/types": "3.8.1-canary-
|
|
23
|
-
"@docusaurus/utils-common": "3.8.1-canary-
|
|
21
|
+
"@docusaurus/logger": "3.8.1-canary-6389",
|
|
22
|
+
"@docusaurus/types": "3.8.1-canary-6389",
|
|
23
|
+
"@docusaurus/utils-common": "3.8.1-canary-6389",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
25
25
|
"execa": "5.1.1",
|
|
26
26
|
"file-loader": "^6.2.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"dedent": "^0.7.0",
|
|
52
52
|
"tmp-promise": "^3.0.3"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "32281a3eb0375ac19c0afc463b3e701b908b7cd6"
|
|
55
55
|
}
|
package/src/markdownLinks.ts
CHANGED
|
@@ -47,9 +47,6 @@ export type SourceToPermalink = Map<
|
|
|
47
47
|
string // Permalink: "/docs/content"
|
|
48
48
|
>;
|
|
49
49
|
|
|
50
|
-
// Note this is historical logic extracted during a 2024 refactor
|
|
51
|
-
// The algo has been kept exactly as before for retro compatibility
|
|
52
|
-
// See also https://github.com/facebook/docusaurus/pull/10168
|
|
53
50
|
export function resolveMarkdownLinkPathname(
|
|
54
51
|
linkPathname: string,
|
|
55
52
|
context: {
|
|
@@ -60,20 +57,45 @@ export function resolveMarkdownLinkPathname(
|
|
|
60
57
|
},
|
|
61
58
|
): string | null {
|
|
62
59
|
const {sourceFilePath, sourceToPermalink, contentPaths, siteDir} = context;
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
if (
|
|
66
|
-
|
|
60
|
+
|
|
61
|
+
// If the link is already @site aliased, there's no need to resolve it
|
|
62
|
+
if (linkPathname.startsWith('@site/')) {
|
|
63
|
+
return sourceToPermalink.get(decodeURIComponent(linkPathname)) ?? null;
|
|
67
64
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
|
|
66
|
+
// Get the dirs to "look into", ordered by priority, when resolving the link
|
|
67
|
+
function getSourceDirsToTry() {
|
|
68
|
+
// /file.md is always resolved from
|
|
69
|
+
// - the plugin content paths,
|
|
70
|
+
// - then siteDir
|
|
71
|
+
if (linkPathname.startsWith('/')) {
|
|
72
|
+
return [...getContentPathList(contentPaths), siteDir];
|
|
73
|
+
}
|
|
74
|
+
// ./file.md and ../file.md are always resolved from
|
|
75
|
+
// - the current file dir
|
|
76
|
+
else if (linkPathname.startsWith('./') || linkPathname.startsWith('../')) {
|
|
77
|
+
return [path.dirname(sourceFilePath)];
|
|
78
|
+
}
|
|
79
|
+
// file.md is resolved from
|
|
80
|
+
// - the current file dir,
|
|
81
|
+
// - then from the plugin content paths,
|
|
82
|
+
// - then siteDir
|
|
83
|
+
else {
|
|
84
|
+
return [
|
|
85
|
+
path.dirname(sourceFilePath),
|
|
86
|
+
...getContentPathList(contentPaths),
|
|
87
|
+
siteDir,
|
|
88
|
+
];
|
|
89
|
+
}
|
|
71
90
|
}
|
|
72
91
|
|
|
73
|
-
const
|
|
92
|
+
const sourcesToTry = getSourceDirsToTry()
|
|
74
93
|
.map((sourceDir) => path.join(sourceDir, decodeURIComponent(linkPathname)))
|
|
75
|
-
.map((source) => aliasedSitePath(source, siteDir))
|
|
76
|
-
|
|
94
|
+
.map((source) => aliasedSitePath(source, siteDir));
|
|
95
|
+
|
|
96
|
+
const aliasedSourceMatch = sourcesToTry.find((source) =>
|
|
97
|
+
sourceToPermalink.has(source),
|
|
98
|
+
);
|
|
77
99
|
|
|
78
100
|
return aliasedSourceMatch
|
|
79
101
|
? sourceToPermalink.get(aliasedSourceMatch) ?? null
|