@docusaurus/plugin-content-docs 0.0.0-6004 → 0.0.0-6006
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/client/docsClientUtils.js +16 -8
- package/package.json +11 -11
- package/src/client/docsClientUtils.ts +17 -8
|
@@ -30,14 +30,22 @@ export function getActivePlugin(allPluginData, pathname, options = {}) {
|
|
|
30
30
|
}
|
|
31
31
|
export const getLatestVersion = (data) => data.versions.find((version) => version.isLast);
|
|
32
32
|
export function getActiveVersion(data, pathname) {
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
// Sort paths so that a match-all version like /docs/* is matched last
|
|
34
|
+
// Otherwise /docs/* would match /docs/1.0.0/* routes
|
|
35
|
+
// This is simplified but similar to the core sortRoutes() logic
|
|
36
|
+
const sortedVersions = [...data.versions].sort((a, b) => {
|
|
37
|
+
if (a.path === b.path) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
if (a.path.includes(b.path)) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
if (b.path.includes(a.path)) {
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
return 0;
|
|
47
|
+
});
|
|
48
|
+
return sortedVersions.find((version) => !!matchPath(pathname, {
|
|
41
49
|
path: version.path,
|
|
42
50
|
exact: false,
|
|
43
51
|
strict: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-6006",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/core": "0.0.0-
|
|
39
|
-
"@docusaurus/logger": "0.0.0-
|
|
40
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
41
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
42
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
43
|
-
"@docusaurus/types": "0.0.0-
|
|
44
|
-
"@docusaurus/utils": "0.0.0-
|
|
45
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
46
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
38
|
+
"@docusaurus/core": "0.0.0-6006",
|
|
39
|
+
"@docusaurus/logger": "0.0.0-6006",
|
|
40
|
+
"@docusaurus/mdx-loader": "0.0.0-6006",
|
|
41
|
+
"@docusaurus/module-type-aliases": "0.0.0-6006",
|
|
42
|
+
"@docusaurus/theme-common": "0.0.0-6006",
|
|
43
|
+
"@docusaurus/types": "0.0.0-6006",
|
|
44
|
+
"@docusaurus/utils": "0.0.0-6006",
|
|
45
|
+
"@docusaurus/utils-common": "0.0.0-6006",
|
|
46
|
+
"@docusaurus/utils-validation": "0.0.0-6006",
|
|
47
47
|
"@types/react-router-config": "^5.0.7",
|
|
48
48
|
"combine-promises": "^1.1.0",
|
|
49
49
|
"fs-extra": "^11.1.1",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=18.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "79b82f5d1cade4e9fedc6c08d9a5dc8ec6559e7f"
|
|
71
71
|
}
|
|
@@ -63,14 +63,23 @@ export function getActiveVersion(
|
|
|
63
63
|
data: GlobalPluginData,
|
|
64
64
|
pathname: string,
|
|
65
65
|
): GlobalVersion | undefined {
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
// Sort paths so that a match-all version like /docs/* is matched last
|
|
67
|
+
// Otherwise /docs/* would match /docs/1.0.0/* routes
|
|
68
|
+
// This is simplified but similar to the core sortRoutes() logic
|
|
69
|
+
const sortedVersions = [...data.versions].sort((a, b) => {
|
|
70
|
+
if (a.path === b.path) {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
if (a.path.includes(b.path)) {
|
|
74
|
+
return -1;
|
|
75
|
+
}
|
|
76
|
+
if (b.path.includes(a.path)) {
|
|
77
|
+
return 1;
|
|
78
|
+
}
|
|
79
|
+
return 0;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return sortedVersions.find(
|
|
74
83
|
(version) =>
|
|
75
84
|
!!matchPath(pathname, {
|
|
76
85
|
path: version.path,
|