@docusaurus/plugin-content-docs 0.0.0-6003 → 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.
@@ -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
- const lastVersion = getLatestVersion(data);
34
- // Last version is a route like /docs/*,
35
- // we need to match it last or it would match /docs/version-1.0/* as well
36
- const orderedVersionsMetadata = [
37
- ...data.versions.filter((version) => version !== lastVersion),
38
- lastVersion,
39
- ];
40
- return orderedVersionsMetadata.find((version) => !!matchPath(pathname, {
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-6003",
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-6003",
39
- "@docusaurus/logger": "0.0.0-6003",
40
- "@docusaurus/mdx-loader": "0.0.0-6003",
41
- "@docusaurus/module-type-aliases": "0.0.0-6003",
42
- "@docusaurus/theme-common": "0.0.0-6003",
43
- "@docusaurus/types": "0.0.0-6003",
44
- "@docusaurus/utils": "0.0.0-6003",
45
- "@docusaurus/utils-common": "0.0.0-6003",
46
- "@docusaurus/utils-validation": "0.0.0-6003",
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": "d4d8bd2115a51f595d7b9133f32b3ba0571c8c02"
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
- const lastVersion = getLatestVersion(data);
67
- // Last version is a route like /docs/*,
68
- // we need to match it last or it would match /docs/version-1.0/* as well
69
- const orderedVersionsMetadata = [
70
- ...data.versions.filter((version) => version !== lastVersion),
71
- lastVersion,
72
- ];
73
- return orderedVersionsMetadata.find(
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,