feat(v2): create common base theme #3752
Closed
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
Originally I actually wanted to fix #3747, for which I just created new webpack alias for theme utils (see first commit 16e09fc). However, then I realized that this is not a good solution in the long term. Thus, I have to came that we need to create new package for the common/shared/reusable parts of any Docusaurus theme.
Similar subject has already been raised in PR #2714. However, in current PR I am only moving the theme utils (mostly to resolve #3747), but this is good starting point for further work to split classic theme.
But, technically, I decided to do this via slightly different approach (opposite of #2714) - a really used theme (note, not preset) can have a base theme, i.e. it will be based on its components/hooks/etc. (Maybe it sounds a little confusing, and we need to think about the better naming/definition). In fact, base theme is essentially a regular plugin theme, which is give reusable parts for using in actual theme (and in subsequent themes too).
This functionality works in the case of using a preset (generally it is use case by default) and if only the theme is used (without preset). Since not everyone uses the classic preset, they can still use base theme's parts. I almost forgot: base/common theme adds webpack alias
theme-utils
, I thought it would be handy for all us.It's more of a POC to show my whole idea. Perhaps the code needs to be improved or modified in some way (not a big deal, though).
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Preview. And of course the command
yarn swizzle @docusaurus/theme-classic Footer
runs without errors anymore.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.)