@docusaurus/core 0.0.0-5816 → 0.0.0-5819
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/server/brokenLinks.js +23 -3
- package/package.json +10 -10
|
@@ -21,13 +21,33 @@ function matchRoutes(routeConfig, pathname) {
|
|
|
21
21
|
}
|
|
22
22
|
function createBrokenLinksHelper({ collectedLinks, routes, }) {
|
|
23
23
|
const validPathnames = new Set(collectedLinks.keys());
|
|
24
|
+
// IMPORTANT: this is an optimization
|
|
25
|
+
// See https://github.com/facebook/docusaurus/issues/9754
|
|
24
26
|
// Matching against the route array can be expensive
|
|
25
27
|
// If the route is already in the valid pathnames,
|
|
26
|
-
// we can avoid matching against it
|
|
27
|
-
const remainingRoutes =
|
|
28
|
+
// we can avoid matching against it
|
|
29
|
+
const remainingRoutes = (function filterRoutes() {
|
|
30
|
+
// Goal: unit tests should behave the same with this enabled or disabled
|
|
31
|
+
const disableOptimization = false;
|
|
32
|
+
if (disableOptimization) {
|
|
33
|
+
return routes;
|
|
34
|
+
}
|
|
35
|
+
// We must consider the "exact" and "strict" match attribute
|
|
36
|
+
// We can only infer pre-validated pathnames from a route from exact routes
|
|
37
|
+
const [validPathnameRoutes, otherRoutes] = lodash_1.default.partition(routes, (route) => route.exact && validPathnames.has(route.path));
|
|
38
|
+
// If a route is non-strict (non-sensitive to trailing slashes)
|
|
39
|
+
// We must pre-validate all possible paths
|
|
40
|
+
validPathnameRoutes.forEach((validPathnameRoute) => {
|
|
41
|
+
if (!validPathnameRoute.strict) {
|
|
42
|
+
validPathnames.add((0, utils_1.addTrailingSlash)(validPathnameRoute.path));
|
|
43
|
+
validPathnames.add((0, utils_1.removeTrailingSlash)(validPathnameRoute.path));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return otherRoutes;
|
|
47
|
+
})();
|
|
28
48
|
function isPathnameMatchingAnyRoute(pathname) {
|
|
29
49
|
if (matchRoutes(remainingRoutes, pathname).length > 0) {
|
|
30
|
-
// IMPORTANT: this is an optimization
|
|
50
|
+
// IMPORTANT: this is an optimization
|
|
31
51
|
// See https://github.com/facebook/docusaurus/issues/9754
|
|
32
52
|
// Large Docusaurus sites have many routes!
|
|
33
53
|
// We try to minimize calls to a possibly expensive matchRoutes function
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-5819",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@babel/runtime": "^7.22.6",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
45
45
|
"@babel/traverse": "^7.22.8",
|
|
46
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
47
|
-
"@docusaurus/logger": "0.0.0-
|
|
48
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
46
|
+
"@docusaurus/cssnano-preset": "0.0.0-5819",
|
|
47
|
+
"@docusaurus/logger": "0.0.0-5819",
|
|
48
|
+
"@docusaurus/mdx-loader": "0.0.0-5819",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "0.0.0-
|
|
51
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
52
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
50
|
+
"@docusaurus/utils": "0.0.0-5819",
|
|
51
|
+
"@docusaurus/utils-common": "0.0.0-5819",
|
|
52
|
+
"@docusaurus/utils-validation": "0.0.0-5819",
|
|
53
53
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.7",
|
|
54
54
|
"@svgr/webpack": "^6.5.1",
|
|
55
55
|
"autoprefixer": "^10.4.14",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"webpackbar": "^5.0.2"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
108
|
-
"@docusaurus/types": "0.0.0-
|
|
107
|
+
"@docusaurus/module-type-aliases": "0.0.0-5819",
|
|
108
|
+
"@docusaurus/types": "0.0.0-5819",
|
|
109
109
|
"@types/detect-port": "^1.3.3",
|
|
110
110
|
"@types/react-dom": "^18.2.7",
|
|
111
111
|
"@types/react-router-config": "^5.0.7",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"engines": {
|
|
125
125
|
"node": ">=18.0"
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "8517ae6f74b9db21114f148d1a05d5af462574a0"
|
|
128
128
|
}
|