-
-
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: allow custom navbarItem types to pass through validation #7231
feat: allow custom navbarItem types to pass through validation #7231
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-7231--docusaurus-2.netlify.app/ |
cc @jaredcbaum , looks relevant for what you did on Ionic doc here:
Looking forward to making all this easier in #7227 |
I attempted another workaround in the latest batch of updates to the ionic docs. This abstracts the validation logic to the Docusaurus config file. I was/am attempting to abstract a common theme that could also have custom schemas based on which site it was used on. I only got far enough for the navbar but theoretically it could be used for other schemas. https://github.com/ionic-team/ionic-docs/blob/feat/plugin-abstraction/docusaurus.config.js#L211-L239 I think this is dancing around a bigger problem though, which is custom navbar parts. It seems as though this is in the works, but figured I'd post in case anyone was looking for an immediate workaround. |
Also, just an idea but I think it would work well to have a generated list of the "native" NavbarItems from the original theme and anything else would be considered custom. In theory it could eliminate the need to prefix with "custom-" |
Thanks @jaredcbaum, another workaround remains useful until we have proper support for this 👍
We could as well allow unknown navbar item types in our navigation instead of constraining to For now prefixing things with |
packages/docusaurus-theme-classic/src/theme/NavbarItem/index.tsx
Outdated
Show resolved
Hide resolved
Size Change: -580 B (0%) Total Size: 802 kB
ℹ️ View Unchanged
|
Motivation
This implements a temporary workaround to support custom navbar item types:
type: "custom-x"
in navbar items (+ arbitrary props) (for now thecustom-
prefix is mandatory)@theme/NavbarItem/ComponentTypes
to register yourcustom-x
componentNote this is a temporary workaround until we provide a better API to register custom navbar item types.
See also: #7227 (comment)
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
dogfood + preview + validation tests
The test section of the website will show a custom navbar item:
https://deploy-preview-7231--docusaurus-2.netlify.app/tests/docs/