@docusaurus/core 0.0.0-6000 → 0.0.0-6003

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.
@@ -95,7 +95,7 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
95
95
  };
96
96
  useEffect(() => {
97
97
  // If IO is not supported. We prefetch by default (only once).
98
- if (!IOSupported && isInternal) {
98
+ if (!IOSupported && isInternal && ExecutionEnvironment.canUseDOM) {
99
99
  if (targetLink != null) {
100
100
  window.docusaurus.prefetch(targetLink);
101
101
  }
@@ -113,19 +113,30 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
113
113
  // https://github.com/remix-run/react-router/blob/v5/packages/react-router-dom/modules/Link.js#L47
114
114
  const hasInternalTarget = !props.target || props.target === '_self';
115
115
  // Should we use a regular <a> tag instead of React-Router Link component?
116
- const isRegularHtmlLink = !targetLink || !isInternal || !hasInternalTarget;
116
+ const isRegularHtmlLink = !targetLink ||
117
+ !isInternal ||
118
+ !hasInternalTarget ||
119
+ // When using the hash router, we can't use the regular <a> link for anchors
120
+ // We need to use React Router to navigate to /#/pathname/#anchor
121
+ // And not /#anchor
122
+ // See also https://github.com/facebook/docusaurus/pull/10311
123
+ (isAnchorLink && router !== 'hash');
117
124
  if (!noBrokenLinkCheck && (isAnchorLink || !isRegularHtmlLink)) {
118
125
  brokenLinks.collectLink(targetLink);
119
126
  }
120
127
  if (props.id) {
121
128
  brokenLinks.collectAnchor(props.id);
122
129
  }
130
+ // These props are only added in unit tests to assert/capture the type of link
131
+ const testOnlyProps = process.env.NODE_ENV === 'test'
132
+ ? { 'data-test-link-type': isRegularHtmlLink ? 'regular' : 'react-router' }
133
+ : {};
123
134
  return isRegularHtmlLink ? (
124
135
  // eslint-disable-next-line jsx-a11y/anchor-has-content, @docusaurus/no-html-links
125
136
  <a ref={innerRef} href={targetLink} {...(targetLinkUnprefixed &&
126
- !isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props}/>) : (<LinkComponent {...props} onMouseEnter={onInteractionEnter} onTouchStart={onInteractionEnter} innerRef={handleRef} to={targetLink}
137
+ !isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props} {...testOnlyProps}/>) : (<LinkComponent {...props} onMouseEnter={onInteractionEnter} onTouchStart={onInteractionEnter} innerRef={handleRef} to={targetLink}
127
138
  // Avoid "React does not recognize the `activeClassName` prop on a DOM
128
139
  // element"
129
- {...(isNavLink && { isActive, activeClassName })}/>);
140
+ {...(isNavLink && { isActive, activeClassName })} {...testOnlyProps}/>);
130
141
  }
131
142
  export default React.forwardRef(Link);
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-6000",
4
+ "version": "0.0.0-6003",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,12 +43,12 @@
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-6000",
47
- "@docusaurus/logger": "0.0.0-6000",
48
- "@docusaurus/mdx-loader": "0.0.0-6000",
49
- "@docusaurus/utils": "0.0.0-6000",
50
- "@docusaurus/utils-common": "0.0.0-6000",
51
- "@docusaurus/utils-validation": "0.0.0-6000",
46
+ "@docusaurus/cssnano-preset": "0.0.0-6003",
47
+ "@docusaurus/logger": "0.0.0-6003",
48
+ "@docusaurus/mdx-loader": "0.0.0-6003",
49
+ "@docusaurus/utils": "0.0.0-6003",
50
+ "@docusaurus/utils-common": "0.0.0-6003",
51
+ "@docusaurus/utils-validation": "0.0.0-6003",
52
52
  "autoprefixer": "^10.4.14",
53
53
  "babel-loader": "^9.1.3",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
@@ -103,8 +103,8 @@
103
103
  "webpackbar": "^5.0.2"
104
104
  },
105
105
  "devDependencies": {
106
- "@docusaurus/module-type-aliases": "0.0.0-6000",
107
- "@docusaurus/types": "0.0.0-6000",
106
+ "@docusaurus/module-type-aliases": "0.0.0-6003",
107
+ "@docusaurus/types": "0.0.0-6003",
108
108
  "@total-typescript/shoehorn": "^0.1.2",
109
109
  "@types/detect-port": "^1.3.3",
110
110
  "@types/react-dom": "^18.2.7",
@@ -124,5 +124,5 @@
124
124
  "engines": {
125
125
  "node": ">=18.0"
126
126
  },
127
- "gitHead": "10f44ae468ae6751fa53eb8af6441265f0e5075c"
127
+ "gitHead": "d4d8bd2115a51f595d7b9133f32b3ba0571c8c02"
128
128
  }