Skip to content

Commit

Permalink
docs: use plugin names and refactor (#2007)
Browse files Browse the repository at this point in the history
  • Loading branch information
SethFalco authored May 15, 2024
1 parent 9a1c749 commit 3bcdc37
Show file tree
Hide file tree
Showing 62 changed files with 136 additions and 884 deletions.
70 changes: 35 additions & 35 deletions docs/02-preset-default.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,41 @@ If you aren't using SVGO directly, like through [SVGR](https://github.com/gregbe

The following plugins are included in `preset-default`, in the order that they're executed:

- [Remove Doctype](/docs/plugins/remove-doctype/)
- [Remove XML Declaration](/docs/plugins/remove-xml-proc-inst/)
- [Remove Comments](/docs/plugins/remove-comments/)
- [Remove Metadata](/docs/plugins/remove-metadata/)
- [Remove Editor Namespace Data](/docs/plugins/remove-editors-ns-data/)
- [Cleanup Attributes](/docs/plugins/cleanup-attrs/)
- [Merge Styles](/docs/plugins/merge-styles/)
- [Inline Styles](/docs/plugins/inline-styles/)
- [Minify Styles](/docs/plugins/minify-styles/)
- [Cleanup IDs](/docs/plugins/cleanup-ids/)
- [Remove Useless Defs](/docs/plugins/remove-useless-defs/)
- [Cleanup Numeric Values](/docs/plugins/cleanup-numeric-values/)
- [Convert Colors](/docs/plugins/convert-colors/)
- [Remove Unknowns and Defaults](/docs/plugins/remove-unknowns-and-defaults/)
- [Remove Non-inheritable Group Attributes](/docs/plugins/remove-non-inheritable-group-attrs/)
- [Remove Useless Stroke and Fill](/docs/plugins/remove-useless-stroke-and-fill/)
- [Remove ViewBox](/docs/plugins/remove-viewbox/)
- [Cleanup Enable Background](/docs/plugins/cleanup-enable-background/)
- [Remove Hidden Elements](/docs/plugins/remove-hidden-elems/)
- [Remove Empty Text](/docs/plugins/remove-empty-text/)
- [Convert Shape to Path](/docs/plugins/convert-shape-to-path/)
- [Convert Ellipse to Circle](/docs/plugins/convert-ellipse-to-circle/)
- [Move Element Attributes to Group](/docs/plugins/move-elems-attrs-to-group/)
- [Move Group Attributes to Element](/docs/plugins/move-group-attrs-to-elem/)
- [Collapse Groups](/docs/plugins/collapse-groups/)
- [Convert Path Data](/docs/plugins/convert-path-data/)
- [Convert Transform](/docs/plugins/convert-transform/)
- [Remove Empty Attributes](/docs/plugins/remove-empty-attrs/)
- [Remove Empty Containers](/docs/plugins/remove-empty-containers/)
- [Remove Unused Namespaces](/docs/plugins/remove-unused-namespaces/)
- [Merge Paths](/docs/plugins/merge-paths/)
- [Sort Attributes](/docs/plugins/sort-attrs/)
- [Sort Defs Children](/docs/plugins/sort-defs-children/)
- [Remove Title](/docs/plugins/remove-title/)
- [Remove Description](/docs/plugins/remove-desc/)
- [removeDoctype](/docs/plugins/removeDoctype/)
- [removeXMLProcInst](/docs/plugins/removeXMLProcInst/)
- [removeComments](/docs/plugins/removeComments/)
- [removeMetadata](/docs/plugins/removeMetadata/)
- [removeEditorsNSData](/docs/plugins/removeEditorsNSData/)
- [cleanupAttrs](/docs/plugins/cleanupAttrs/)
- [mergeStyles](/docs/plugins/mergeStyles/)
- [inlineStyles](/docs/plugins/inlineStyles/)
- [minifyStyles](/docs/plugins/minifyStyles/)
- [cleanupIds](/docs/plugins/cleanupIds/)
- [removeUselessDefs](/docs/plugins/removeUselessDefs/)
- [cleanupNumericValues](/docs/plugins/cleanupNumericValues/)
- [convertColors](/docs/plugins/convertColors/)
- [removeUnknownsAndDefaults](/docs/plugins/removeUnknownsAndDefaults/)
- [removeNonInheritableGroupAttrs](/docs/plugins/removeNonInheritableGroupAttrs/)
- [removeUselessStrokeAndFill](/docs/plugins/removeUselessStrokeAndFill/)
- [removeViewBox](/docs/plugins/removeViewBox/)
- [cleanupEnableBackground](/docs/plugins/cleanupEnableBackground/)
- [removeHiddenElems](/docs/plugins/removeHiddenElems/)
- [removeEmptyText](/docs/plugins/removeEmptyText/)
- [convertShapeToPath](/docs/plugins/convertShapeToPath/)
- [convertEllipseToCircle](/docs/plugins/convertEllipseToCircle/)
- [moveElemsAttrsToGroup](/docs/plugins/moveElemsAttrsToGroup/)
- [moveGroupAttrsToElems](/docs/plugins/moveGroupAttrsToElems/)
- [collapseGroups](/docs/plugins/collapseGroups/)
- [convertPathData](/docs/plugins/convertPathData/)
- [convertTransform](/docs/plugins/convertTransform/)
- [removeEmptyAttrs](/docs/plugins/removeEmptyAttrs/)
- [removeEmptyContainers](/docs/plugins/removeEmptyContainers/)
- [removeUnusedNS](/docs/plugins/removeUnusedNS/)
- [mergePaths](/docs/plugins/mergePaths/)
- [sortAttrs](/docs/plugins/sortAttrs/)
- [sortDefsChildren](/docs/plugins/sortDefsChildren/)
- [removeTitle](/docs/plugins/removeTitle/)
- [removeDesc](/docs/plugins/removeDesc/)

## Disable a Plugin

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Add Attributes to Elements
title: addAttributesToSVGElement
svgo:
pluginId: addAttributesToSVGElement
parameters:
Expand All @@ -16,19 +16,3 @@ Adds attributes to the outer most [`<svg>`](https://developer.mozilla.org/docs/W
This plugin is only safe to use when a map of key/value pairs is passed. If you pass an array of keys to declare empty attributes, this will produce an malformed SVG that's only usable inline an HTML document.

:::

## Usage

<PluginUsage />

### Parameters

<PluginParams />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/addAttributesToSVGElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Add Classes to SVG
title: addClassesToSVGElement
svgo:
pluginId: addClassesToSVGElement
parameters:
Expand All @@ -21,19 +21,3 @@ If there is no `class` attribute to begin with, it will be added. However, if th
If you have a standalone SVG, this is not an optimization and will increase the size of the SVG document. This plugin is only relevant when considering multiple SVGs that may be inlined a parent document.

By adding classes, if the parent document is aware, you can share styles across all inlined SVG elements.

## Usage

<PluginUsage />

### Parameters

<PluginParams />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/addClassesToSVGElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Cleanup Attributes
title: cleanupAttrs
svgo:
pluginId: cleanupAttrs
defaultPlugin: true
Expand All @@ -21,19 +21,3 @@ svgo:
Removes redundant whitespaces from attribute values.

This will not modify the attribute keys, nor remove them if the value becomes empty after optimization.

## Usage

<PluginUsage />

### Parameters

<PluginParams />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/cleanupAttrs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Cleanup Enable Background
title: cleanupEnableBackground
svgo:
pluginId: cleanupEnableBackground
defaultPlugin: true
Expand All @@ -19,15 +19,3 @@ This plugin will:
Some browsers don't support `enable-background`, so it's best to avoid the attribute regardless.

:::

## Usage

<PluginUsage />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/cleanupEnableBackground.js
20 changes: 2 additions & 18 deletions docs/03-plugins/cleanup-ids.mdx → docs/03-plugins/cleanupIds.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Cleanup IDs
title: cleanupIds
svgo:
pluginId: cleanupIds
parameters:
Expand Down Expand Up @@ -35,24 +35,8 @@ Between v2 and v3, the plugin ID was renamed from `cleanupIDs` to `cleanupIds`,

This plugin has been known to cause problems when inlining multiple SVGs in the same parent document. Due to the predictable algorithm used to minify IDs, separate documents that are run though SVGO may end up with clashing IDs.

You can work around this by enabling the [**Prefix IDs**](/docs/plugins/prefix-ids/) plugin. Alternatively, you can set the `minify` parameter to `false`, however this will not resolve the issue if your SVGs already had clashing IDs to start with.
You can work around this by enabling the [prefixIds](/docs/plugins/prefixIds/) plugin. Alternatively, you can set the `minify` parameter to `false`, however this will not resolve the issue if your SVGs already had clashing IDs to start with.

See [facebook/docusaurus#8297](https://github.com/facebook/docusaurus/issues/8297) for more context.

:::

## Usage

<PluginUsage />

### Parameters

<PluginParams />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/cleanupIds.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Cleanup List of Values
title: cleanupListOfValues
svgo:
pluginId: cleanupListOfValues
parameters:
Expand All @@ -20,19 +20,3 @@ svgo:
# Cleanup List of Values

Rounds numeric values in attributes, such as those found in [`viewBox`](https://developer.mozilla.org/docs/Web/SVG/Attribute/viewBox), [`enable-background`](https://developer.mozilla.org/docs/Web/SVG/Attribute/enable-background), and [`points`](https://developer.mozilla.org/docs/Web/SVG/Attribute/points).

## Usage

<PluginUsage />

### Parameters

<PluginParams />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/cleanupListOfValues.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Cleanup Numeric Values
title: cleanupNumericValues
svgo:
pluginId: cleanupNumericValues
defaultPlugin: true
Expand All @@ -19,19 +19,3 @@ svgo:
---

Rounds numeric values, and removes the unit when it's `px` as this is the default.

## Usage

<PluginUsage />

### Parameters

<PluginParams />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/cleanupNumericValues.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Collapse Groups
title: collapseGroups
svgo:
pluginId: collapseGroups
defaultPlugin: true
Expand All @@ -11,18 +11,6 @@ Groups can be formed using the [`<g>`](https://developer.mozilla.org/docs/Web/SV

:::info

This plugin doesn't remove empty groups. That's handled by the [**Remove Empty Containers**](/docs/plugins/remove-empty-containers/) plugin which is enabled by default.
This plugin doesn't remove empty groups. That's handled by the [removeEmptyContainers](/docs/plugins/removeEmptyContainers/) plugin which is enabled by default.

:::

## Usage

<PluginUsage />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/collapseGroups.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Convert Colors
title: convertColors
svgo:
pluginId: convertColors
defaultPlugin: true
Expand Down Expand Up @@ -38,19 +38,3 @@ Colors can be represented in various notations, the following table showcases so
| `purple` | `rgb(128, 0, 128)` | `#800080` | |

It makes no difference which format is received by a client, and each one has wide support across browsers and image viewing software.

## Usage

<PluginUsage />

### Parameters

<PluginParams />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/convertColors.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
---
title: Convert Ellipse to Circle
title: convertEllipseToCircle
svgo:
pluginId: convertEllipseToCircle
defaultPlugin: true
---

Convert non-eccentric [`<ellipse>`](https://developer.mozilla.org/docs/Web/SVG/Element/ellipse) elements to [`<circle>`](https://developer.mozilla.org/docs/Web/SVG/Element/circle) elements.

## Usage

<PluginUsage />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/convertEllipseToCircle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Convert One-Stop Gradients
title: convertOneStopGradients
svgo:
pluginId: convertOneStopGradients
---
Expand All @@ -9,15 +9,3 @@ Converts the [`<linearGradient>`](https://developer.mozilla.org/docs/Web/SVG/Ele
These nodes contain [`<stop>`](https://developer.mozilla.org/docs/Web/SVG/Element/stop) elements, which represent various colors to transition between. However, if a gradient only contains a single `<stop>`, then it's effecitively a solid fill.

Definitions of the gradients are removed, and the parent [`<defs>`](https://developer.mozilla.org/docs/Web/SVG/Element/defs) node is removed if it has no children after optimization. The `xlink:href` namespace is also removed if there are no remaining elements using this attribute.

## Usage

<PluginUsage />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/convertOneStopGradients.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Convert Path Commands
title: convertPathData
svgo:
pluginId: convertPathData
defaultPlugin: true
Expand Down Expand Up @@ -69,19 +69,3 @@ This plugin uses multiple techniques to either reduce the number of instructions
- Round numeric values using conventional rounding rules.

You can read more about the plugins capabilities by going through the individual parameters.

## Usage

<PluginUsage />

### Parameters

<PluginParams />

## Demo

<PluginDemo />

## Implementation

- https://github.com/svg/svgo/blob/main/plugins/convertPathData.js
Loading

0 comments on commit 3bcdc37

Please sign in to comment.