Support version switcher on versioned docs #573
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The following is changes to the version switcher as part of #566
It was discovered when using Docusaurus native versioning the version switcher would not appear unless you were on a versioned doc because the URL path was looking for
/24.1/
etc however this is not included when using docusaurus versioning.Github Code Summary.
Enhancements to UI rendering:
currentVersion
is undefined, ensuring the UI remains functional and user-friendly.currentVersion
gracefully.This pull request refines the
VersionSwitcher
component inVersionSwitcher.tsx
to improve its handling of edge cases and enhance code robustness. The changes primarily address potential issues with undefined values and simplify conditional logic.Improvements to edge case handling:
pathname.startsWith
check to remove the trailing slash when verifying the/platform-enterprise
prefix, ensuring consistency in URL matching.currentVersion
in the filter logic to prevent potential errors whencurrentVersion
is undefined.urlSuffix
to handle cases wherecurrentVersion
is not defined, defaulting to an empty string.