feat(v2): add @theme-original alias to give access to pre-swizzled components #2455
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.
Motivation
Provide an alias for theme components so that they can be semi-swizzled. Meaning you swizzle a component but only to wrap things around it, possibly to call new lifecycle logic or have components above/below it.
For example, I can now do this
and get this
This is partially inspired by VuePress (although Endi and I already had this idea long ago when we were building themes). Libra docs is moving to v2 and wants this level of customization.
This
@theme-original
alias will also allow us to specify slot props (components as props) which serve to inject components somewhere into a component. We could do this for the various doc and blog items.Follow Up
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Modified unit tests and added example.
Related PRs
(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.)