Skip to content
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

Merged
merged 27 commits into from
Jan 30, 2025

Conversation

hrumhurum
Copy link
Contributor

@hrumhurum hrumhurum commented Jan 18, 2025

Motivation

Fix #10833

The docsVersionDropdown navbar item supports a new versions attribute to filter/whitelist displayed versions. Only the provided versions will be displayed.

Example:

{
  type: 'docsVersionDropdown',
  versions: ['1.0.1', '2.1.1']
},

Also gives the ability to override version attributes (for now, only display label) by providing an object.

{
  type: 'docsVersionDropdown',
  versions: {
  '1.0.1': {label: '1.x'},
  '2.1.1': {label: '2.x'},
},

Test Plan

  1. Go to the deploy preview website
  2. Locate the docs version dropdown in the upper part of the website
  3. Click on the dropdown
  4. Notice how the version titles are customized
  5. Notice how the list of versions are customized to display just a subset of versions
  6. Visit Docusaurus documentation preview to take a look at the documentation for new functionality

Test links

https://deploy-preview-10852--docusaurus-2.netlify.app/

Docs:

Preview on another site: https://gp-temp-docusaurus-app1.netlify.app/eazfuscator.net

@facebook-github-bot
Copy link
Contributor

Hi @hrumhurum!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link

netlify bot commented Jan 18, 2025

[V2]

Name Link
🔨 Latest commit 5475e3b
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/679ba76f21581f0008e76440
😎 Deploy Preview https://deploy-preview-10852--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Jan 18, 2025

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🔴 46 🟢 98 🟢 96 🟢 100 Report
/docs/installation 🟠 51 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 71 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 59 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 65 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 63 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 73 🟢 100 🟢 100 🟠 86 Report

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jan 18, 2025
Copy link
Collaborator

@slorber slorber left a 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

@slorber slorber changed the title Implementation and docs for versions configuration of "docsVersionDropdown" navbar item feat(theme):Add versions attribute to docsVersionDropdown navbar item Jan 20, 2025
@slorber slorber changed the title feat(theme):Add versions attribute to docsVersionDropdown navbar item feat(theme): add versions attribute to docsVersionDropdown navbar item Jan 20, 2025
@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Jan 20, 2025
@hrumhurum hrumhurum requested a review from slorber January 20, 2025 14:12
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still think we shouldn't include the "version name/label shortcut" in this PR, and discuss it independently in another proposal.

Let me know if you can simplify your code, otherwise I'll do it

@hrumhurum hrumhurum requested a review from slorber January 28, 2025 13:19
@slorber slorber added the Argos Add this label to run UI visual regression tests. See argos.yml GH action. label Jan 30, 2025
Copy link

argos-ci bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ Auto-approved build (Review) 2 changed Jan 30, 2025, 4:31 PM

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks 👍

I simplified a bit and handled a few edge cases, and it's working as I expect now.

Notably, if the dropdown only has one version in it, and a custom label is provided, we should display that version also as the dropdown hover link, and ensure the custom provided label is also used in it.

CleanShot 2025-01-30 at 17 23 10

@slorber slorber merged commit 4d7a289 into facebook:main Jan 30, 2025
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Argos Add this label to run UI visual regression tests. See argos.yml GH action. CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limiting number of versions visible in the version dropdown switch
3 participants