feat(svgr): create new Docusaurus SVGR plugin (#10677)

This commit is contained in:
Sébastien Lorber 2024-11-29 17:26:34 +01:00 committed by GitHub
parent 750edc78ff
commit df6f53a2f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 1247 additions and 149 deletions

View file

@ -23,8 +23,11 @@ These plugins will add a useful behavior to your Docusaurus site.
- [@docusaurus/plugin-debug](./plugin-debug.mdx)
- [@docusaurus/plugin-sitemap](./plugin-sitemap.mdx)
- [@docusaurus/plugin-svgr](./plugin-svgr.mdx)
- [@docusaurus/plugin-rsdoctor](./plugin-rsdoctor.mdx)
- [@docusaurus/plugin-pwa](./plugin-pwa.mdx)
- [@docusaurus/plugin-client-redirects](./plugin-client-redirects.mdx)
- [@docusaurus/plugin-ideal-image](./plugin-ideal-image.mdx)
- [@docusaurus/plugin-google-analytics](./plugin-google-analytics.mdx)
- [@docusaurus/plugin-google-gtag](./plugin-google-gtag.mdx)
- [@docusaurus/plugin-google-tag-manager](./plugin-google-tag-manager.mdx)

View file

@ -0,0 +1,55 @@
---
sidebar_position: 7
slug: /api/plugins/@docusaurus/plugin-svgr
---
# 📦 plugin-svgr
import APITable from '@site/src/components/APITable';
An [SVGR](https://react-svgr.com/) plugin to transform SVG files into React components automatically at build time.
## Installation {#installation}
```bash npm2yarn
npm install --save @docusaurus/plugin-svgr
```
:::tip
If you use the preset `@docusaurus/preset-classic`, you don't need to install this plugin as a dependency.
You can configure this plugin through the [preset options](../../using-plugins.mdx#docusauruspreset-classic).
:::
## Configuration {#configuration}
Accepted fields:
```mdx-code-block
<APITable>
```
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `svgrConfig` | `object` | `{}` | The [SVGR config options](https://react-svgr.com/docs/options/), forwarded as is |
```mdx-code-block
</APITable>
```
### Example configuration {#ex-config}
You can configure this plugin through plugin options.
```js config-tabs
// Preset Options: svgr
// Plugin Options: @docusaurus/plugin-svgr
const config = {
svgrConfig: {
/* SVGR config */
},
};
```