Skip to content

Commit

Permalink
Fix heading/TOC/anchor links with hash router
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Feb 22, 2024
1 parent 4c5a9de commit c22da5a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/docusaurus/src/client/exports/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,10 @@ function Link(
? maybeAddBaseUrl(targetLinkWithoutPathnameProtocol)
: undefined;

// TODO not temp hack
// TODO temporary hack
if (router === 'hash' && targetLink?.startsWith('./')) {
targetLink = targetLink?.slice(1);
}
console.log('link', {
before: targetLinkWithoutPathnameProtocol,
after: targetLink,
});

if (targetLink && isInternal) {
targetLink = applyTrailingSlash(targetLink, {trailingSlash, baseUrl});
Expand Down Expand Up @@ -157,8 +153,7 @@ function Link(
const hasInternalTarget = !props.target || props.target === '_self';

// Should we use a regular <a> tag instead of React-Router Link component?
const isRegularHtmlLink =
!targetLink || !isInternal || !hasInternalTarget || isAnchorLink;
const isRegularHtmlLink = !targetLink || !isInternal || !hasInternalTarget;

if (!noBrokenLinkCheck && (isAnchorLink || !isRegularHtmlLink)) {
brokenLinks.collectLink(targetLink!);
Expand Down

0 comments on commit c22da5a

Please sign in to comment.