diff --git a/src/components/Card/styles.tsx b/src/components/Card/styles.tsx index 2a48f6da5af..9bd84131226 100644 --- a/src/components/Card/styles.tsx +++ b/src/components/Card/styles.tsx @@ -1,6 +1,6 @@ import React from "react"; import styled from "@emotion/styled"; -import Link from "next/link"; +import InternalLink from "../InternalLink"; import {MQFablet, MQDesktop} from "../media"; @@ -30,7 +30,7 @@ const docsCard: React.FC = ({ }) => { if (!href) return
{children}
; return ( - + {external && ( = ({ )}
{children}
- +
); }; diff --git a/src/components/Menu/Directory/index.tsx b/src/components/Menu/Directory/index.tsx index 35405e70606..02f2c3934a3 100644 --- a/src/components/Menu/Directory/index.tsx +++ b/src/components/Menu/Directory/index.tsx @@ -72,6 +72,7 @@ class DirectoryGroup extends React.Component< if (this.itemsToDisplay.length === 0) { return <>; } + return (
@@ -82,7 +83,7 @@ class DirectoryGroup extends React.Component< {this.itemsToDisplay.map((item) => ( diff --git a/src/components/Menu/VersionSwitcher/index.tsx b/src/components/Menu/VersionSwitcher/index.tsx index 4aa67a3a123..04b1691abdb 100644 --- a/src/components/Menu/VersionSwitcher/index.tsx +++ b/src/components/Menu/VersionSwitcher/index.tsx @@ -85,8 +85,8 @@ export function VersionSwitcher({url}) { const lib = directory["lib"].items; const libLegacy = directory["lib-v1"].items; -const libLegacyPaths = []; -const libPaths = []; +const libLegacyPaths: string[] = []; +const libPaths: string[] = []; const libItemsAndPaths: [object, string[]][] = [ [lib, libPaths], [libLegacy, libLegacyPaths], @@ -130,10 +130,20 @@ export function LibVersionSwitcher({ urlEnd = url.split("/lib")[1]; } + // Function to remove query string parameters before checking if href is included in the list of possibilities. + // This is so we are only comparing the paths without the query string parameters to avoid false negatives. + function isHrefIncluded(href: string, paths: string[]) { + href = href.split("#")[0]; + if (href.endsWith("/")) { + href = href.substring(0, href.length-1); + } + return paths.includes(href); + } + const leftHref = "/lib-v1" + urlEnd; const leftOption = { title: legacyVersion, - href: libLegacyPaths.includes(leftHref) + href: isHrefIncluded(leftHref, libLegacyPaths) ? leftHref : "/lib-v1/" + filter, }; @@ -141,7 +151,7 @@ export function LibVersionSwitcher({ const rightHref = "/lib" + urlEnd; const rightOption = { title: `${latestVersion} (latest)`, - href: libPaths.includes(rightHref) ? rightHref : "/lib/" + filter, + href: isHrefIncluded(rightHref, libPaths) ? rightHref : "/lib/" + filter, }; return (