Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/theme/DocSidebar/Desktop/ProductSwitcher/VersionSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@ const VersionSwitcher = ({ isOpen, setIsOpen }) => {

if (typeof window === "undefined") return null;
if (!versions) return null;
if (!location.pathname.startsWith("/platform-enterprise/")) return null;

if (!location.pathname.startsWith("/platform-enterprise")) return null;

const items = versions.filter(
(version) => version.label !== currentVersion.label,
(version) => version.label !== currentVersion?.label,
);

// Extract the part of the URL after the current version
const currentVersionPrefix = `/platform-enterprise/${currentVersion.label}`;
const urlSuffix = location.pathname.replace(currentVersionPrefix, "");
let urlSuffix = "";

if (
currentVersion &&
location.pathname.startsWith(`/platform-enterprise/${currentVersion.label}`)
) {
const currentVersionPrefix = `/platform-enterprise/${currentVersion.label}`;
urlSuffix = location.pathname.replace(currentVersionPrefix, "");
}

return (
<>
Expand All @@ -58,8 +65,10 @@ const VersionSwitcher = ({ isOpen, setIsOpen }) => {
ref={dropdownRef}
>
<span>
v{currentVersion.label}{" "}
{currentVersion.label == versions[0].label ? " (current)" : ""}
{currentVersion ? `v${currentVersion.label}` : "Version"}{" "}
{currentVersion && currentVersion.label === versions[0].label
? " (current)"
: ""}
</span>
</button>
{isOpen && (
Expand Down
Loading