mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-02 08:19:07 +02:00
feat(v2): update swizzle command to suggest component/theme (#3021)
* update swizzle command * change messages * fix formatting * add docs * fix component lisiting * allow themes to provide a list for safe swizzle components * support both commanjs and ES exports * fix debug plugin doesn't swizzle * add dos * remove unsed file * fix docs plugin not swizzle properly * fix console.log * use new validate * fix linting * use config options for plugin * rerun test * fix type * add a comment * Update packages/docusaurus/src/commands/swizzle.ts * Update packages/docusaurus/src/commands/swizzle.ts Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
parent
f234c407f1
commit
ef9314e5a4
7 changed files with 291 additions and 50 deletions
|
@ -79,7 +79,7 @@ We highly discourage swizzling of components until we've reached a Beta stage. T
|
|||
Change any Docusaurus theme components to your liking with `docusaurus swizzle`.
|
||||
|
||||
```shell
|
||||
docusaurus swizzle <themeName> [componentName] [siteDir]
|
||||
docusaurus swizzle [themeName] [componentName] [siteDir]
|
||||
|
||||
# Example (leaving out the siteDir to indicate this directory)
|
||||
docusaurus swizzle @docusaurus/theme-classic DocSidebar
|
||||
|
@ -87,12 +87,16 @@ docusaurus swizzle @docusaurus/theme-classic DocSidebar
|
|||
|
||||
Running the command will copy the relevant theme files to your site folder. You may then make any changes to it and Docusaurus will use it instead of the one provided from the theme.
|
||||
|
||||
`docusaurus swizzle` without `themeName` lists all the themes available for swizzling similarly `docusaurus swizzle <themeName>` without `componentName` lists all the components available for swizzling.
|
||||
|
||||
#### Options
|
||||
|
||||
| Name | Description |
|
||||
| ------------------ | ------------------------------------- |
|
||||
| `themeName` | The name of the theme you are using. |
|
||||
| `swizzleComponent` | The name of the component to swizzle. |
|
||||
| Name | Description |
|
||||
| ------------------ | ---------------------------------------|
|
||||
| `themeName` | The name of the theme you are using. |
|
||||
| `swizzleComponent` | The name of the component to swizzle. |
|
||||
| `--danger` | Allow swizzling of unstable components |
|
||||
| `--typescript` | Swizzle typescript components |
|
||||
|
||||
To unswizzle a component, simply delete the files of the swizzled component.
|
||||
|
||||
|
|
|
@ -509,6 +509,24 @@ module.exports = function (context, options) {
|
|||
};
|
||||
```
|
||||
|
||||
## `getSwizzleComponentList()`
|
||||
|
||||
Return a list of stable component that are considered as safe for swizzling. These components will be listed in swizzle component without `--danger`. All the components are considers unstable by default. If an empty array is returned then all components are considered unstable, if `undefined` is returned then all component are considered stable.
|
||||
|
||||
```js {0-12} title="my-theme/src/index.js"
|
||||
const swizzleAllowedComponents = [
|
||||
'CodeBlock',
|
||||
'DocSidebar',
|
||||
'Footer',
|
||||
'NotFound',
|
||||
'SearchBar',
|
||||
'hooks/useTheme',
|
||||
'prism-include-languages',
|
||||
];
|
||||
|
||||
module.exports.getSwizzleComponentList = () => swizzleAllowedComponents;
|
||||
```
|
||||
|
||||
## `getClientModules()`
|
||||
|
||||
Returns an array of paths to the modules that are to be imported in the client bundle. These modules are imported globally before React even renders the initial UI.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue