Repository navigation
Added onlyShowOnActiveDoc property to DocsVersionDropdownNavbarItem - #5756
Leander-van-Boven wants to merge 5 commits into
Conversation
The newly added property, when set to `true` in the config, will only show this `DocsVersionDropdownNavbarItem` on the doc pages of its associated docs plugin.
Added onlyShowOnActiveDoc property
Update validateThemeConfig.ts
|
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! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
Hi @Leander-van-Boven, I understand this use-case We already plan to add a system of "navbar activation strategy", so that all pages do not share the same navbar items. We also plan to provide the ability to create your own custom navbar items in the future. Considering we plan a better API for this feature, I'd rather not add such a temporary option. Note, you should be able to achieve what you want in the meantime thanks to swizzle / wrapping the original element, as suggested here: I'm also not a big fan of having the navbar item returning null. |
They're already swizzling the comp, they just felt like it's worth contributing to the original code base🧐 Also, I think this does look like an intuitive API without going too much into the impl details? |
It is intuitive but I'd rather have something more general, and also composable.
A boolean wouldn't allow any composition, and we'll need to add support for this everywhere. I'd rather first add a generic low-level API to solve this problem in general, and only then, if it is not intuitive enough, add a shortcut for convenience |
|
Ah, makes sense. So we should turn back to #5360 one day? We should ship category index pages soon :P |
|
Yes we'll get back to it later, probably after v2.0. We need to think about the big picture and make something consistent: navbar, doc sidebar, blog sidebar, footer... all could technically benefit from this kind of behavior |
I can see the argument, and I'm fine with that. As @Josh-Cena mentioned, we will use the swizzled version for now, so we at least have the preferred behaviour until it will be officially supported. I'll keep my eye out for that. Thanks for the effort anyways! :) |
Motivation
When using a multi-instanced, versioned docs website with DocsVersionDropdowns, these are always displayed throughout the whole website (even on normal/static pages that aren't part of the docs). My proposed changes will cause the DocsVersionDropdowns to only be shown when browsing its associated docs-plugin path.
Not only makes this more sense, and does it look prettier. It may also speed up initial page loading, as those dropdowns that don't need to be displayed are never generated.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
I am already using the proposed changes in staging, soon to be production.
How to use this feature:
When browsing
docs-1only the first dropdown should be displayed, idem dito fordocs-2and the second dropdown.Related PRs
#5360 was mentioned by Josh-Cena when discussing this PR.
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)
This PR might require some documentation updates (config.js, doc multi-instancing/versioning pages), which I am willing to do if this PR gets approved.