@docusaurus/core 0.0.0-5814 → 0.0.0-5817

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.
@@ -99,8 +99,11 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
99
99
  }, [ioRef, targetLink, IOSupported, isInternal]);
100
100
  // It is simple local anchor link targeting current page?
101
101
  const isAnchorLink = targetLink?.startsWith('#') ?? false;
102
+ // See also RR logic:
103
+ // https://github.com/remix-run/react-router/blob/v5/packages/react-router-dom/modules/Link.js#L47
104
+ const hasInternalTarget = !props.target || props.target === '_self';
102
105
  // Should we use a regular <a> tag instead of React-Router Link component?
103
- const isRegularHtmlLink = !targetLink || !isInternal || isAnchorLink;
106
+ const isRegularHtmlLink = !targetLink || !isInternal || !hasInternalTarget || isAnchorLink;
104
107
  if (!noBrokenLinkCheck && (isAnchorLink || !isRegularHtmlLink)) {
105
108
  brokenLinks.collectLink(targetLink);
106
109
  }
@@ -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 as an optimization
27
- const remainingRoutes = routes.filter((route) => !validPathnames.has(route.path));
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 here
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-5814",
4
+ "version": "0.0.0-5817",
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-5814",
47
- "@docusaurus/logger": "0.0.0-5814",
48
- "@docusaurus/mdx-loader": "0.0.0-5814",
46
+ "@docusaurus/cssnano-preset": "0.0.0-5817",
47
+ "@docusaurus/logger": "0.0.0-5817",
48
+ "@docusaurus/mdx-loader": "0.0.0-5817",
49
49
  "@docusaurus/react-loadable": "5.5.2",
50
- "@docusaurus/utils": "0.0.0-5814",
51
- "@docusaurus/utils-common": "0.0.0-5814",
52
- "@docusaurus/utils-validation": "0.0.0-5814",
50
+ "@docusaurus/utils": "0.0.0-5817",
51
+ "@docusaurus/utils-common": "0.0.0-5817",
52
+ "@docusaurus/utils-validation": "0.0.0-5817",
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-5814",
108
- "@docusaurus/types": "0.0.0-5814",
107
+ "@docusaurus/module-type-aliases": "0.0.0-5817",
108
+ "@docusaurus/types": "0.0.0-5817",
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": "67b273740f8d1404edf4307185f21ab3b4b37032"
127
+ "gitHead": "f2a043446c467462a95ace4fcd42e381562118f9"
128
128
  }