-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(theme): add versions
attribute to docsVersionDropdown
navbar item
#10852
base: main
Are you sure you want to change the base?
Conversation
…ionDropdown" navbar item
…rsionDropdown" navbar item
…sVersionDropdown" navbar item
Hi @hrumhurum! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
…ration of "docsVersionDropdown" navbar item
…ion of "docsVersionDropdown" navbar item
…"docsVersionDropdown" navbar item
…"docsVersionDropdown" navbar item
…on docs of "docsVersionDropdown" navbar item
…gurations in "docsVersionDropdown" navbar item
…ions in "docsVersionDropdown" navbar item
…navbar item: code refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature works thanks 👍
But I'd like a few things changed
packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx
Show resolved
Hide resolved
// that's why we use 'version.label' as a secondary version identifier | ||
// that can be referenced in configuration | ||
const label = version.label; | ||
if (!versionMap.has(label)) versionMap.set(label, version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not super fan of this logic.
We don't do this kind of thing anywhere else in the codebase so I'd prefer not introduce this here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of that too but it's a workaround for a serious usability omission. Without that logic, a user faces a specifically annoying inconvenience.
Suppose a user wants to restrict the displayed versions to:
versions: ['2024.3','2024.2','2024.1','2023.4']
But without that logic, that aforementioned statement will not work. The user will be forced to specify something hacky like:
versions: ['current','2024.2','2024.1','2023.4']
or even:
versions: ['next','current','2024.1','2023.4']
This is technically ok, but it breaks mental expectations of the user. It can be clearly seen in the guide: it is simple now, but if we try to communicate "you cannot specify the current version by its true name, you must use the special keyword name 'current' because we have particular internals XXX in our code". Well, it will look inconvenient and broken to the user.
The right way to overcome that is to add the original name property to the GlobalVersion
type:
export type GlobalVersion = {
name: string;
+ /** The true version name as defined in the config */
+ canonicalName: string;
label: string;
isLast: boolean;
path: string;
/** The doc with `slug: /`, or first doc in first sidebar */
mainDocId: string;
docs: GlobalDoc[];
/** Unversioned IDs. In development, this list is empty. */
draftIds: string[];
sidebars?: {[sidebarId: string]: GlobalSidebar};
};
and then use it as a secondary (or primary) version identifier.
versions
attribute to docsVersionDropdown
navbar item
versions
attribute to docsVersionDropdown
navbar itemversions
attribute to docsVersionDropdown
navbar item
…m: inline options schema
… the versioning guide
…m: cleaned up reference docs
Motivation
Fix #10833
The
docsVersionDropdown
navbar item supports a newversions
attribute to filter/whitelist displayed versions. Only the provided versions will be displayed.Example:
Also gives the ability to override version attributes (for now, only display
label
) by providing an object.Test Plan
Test links
Deploy preview: https://gp-temp-docusaurus-app1.netlify.app/eazfuscator.net