diff --git a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DefaultNavbarItem.tsx b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DefaultNavbarItem.tsx index 5c8aa9751f..80659c6d0e 100644 --- a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DefaultNavbarItem.tsx +++ b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DefaultNavbarItem.tsx @@ -28,6 +28,9 @@ function NavLink({ activeClassName?: string; prependBaseUrlToHref?: string; } & ComponentProps<'a'>) { + // TODO all this seems hacky + // {to: 'version'} should probably be forbidden, in favor of {to: '/version'} + const toUrl = useBaseUrl(to); const activeBaseUrl = useBaseUrl(activeBasePath); const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true}); return ( @@ -41,7 +44,7 @@ function NavLink({ : { isNavLink: true, activeClassName, - to, + to: toUrl, ...(activeBasePath || activeBaseRegex ? { isActive: (_match, location) => diff --git a/packages/docusaurus/src/client/exports/Link.tsx b/packages/docusaurus/src/client/exports/Link.tsx index 345db0df12..5f85cdff18 100644 --- a/packages/docusaurus/src/client/exports/Link.tsx +++ b/packages/docusaurus/src/client/exports/Link.tsx @@ -11,7 +11,6 @@ import {NavLink, Link as RRLink} from 'react-router-dom'; import isInternalUrl from './isInternalUrl'; import ExecutionEnvironment from './ExecutionEnvironment'; import {useLinksCollector} from '../LinksCollector'; -import {useBaseUrlUtils} from './useBaseUrl'; declare global { interface Window { @@ -38,20 +37,13 @@ function Link({ 'data-noBrokenLinkCheck': noBrokenLinkCheck, ...props }: Props): JSX.Element { - const {withBaseUrl} = useBaseUrlUtils(); const linksCollector = useLinksCollector(); // IMPORTANT: using to or href should not change anything // For example, MDX links will ALWAYS give us the href props // Using one prop or the other should not be used to distinguish // internal links (/docs/myDoc) from external links (https://github.com) - const targetLinkUnprefixed = to || href; - - // Automatically apply base url in links - const targetLink = - typeof targetLinkUnprefixed !== 'undefined' - ? withBaseUrl(targetLinkUnprefixed) - : undefined; + const targetLink = to || href; const isInternal = isInternalUrl(targetLink); const preloaded = useRef(false);