mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-25 11:18:35 +01:00
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { optimize as optimizeSVGNative } from 'svgo'
|
|
|
|
export const toInnerSvg = (input: string) =>
|
|
optimizeSVGNative(input, {
|
|
plugins: [
|
|
'removeDoctype',
|
|
'removeXMLProcInst',
|
|
'removeComments',
|
|
'removeMetadata',
|
|
'removeXMLNS',
|
|
'removeEditorsNSData',
|
|
'cleanupAttrs',
|
|
'minifyStyles',
|
|
'convertStyleToAttrs',
|
|
'cleanupIds',
|
|
'removeRasterImages',
|
|
'removeUselessDefs',
|
|
'cleanupNumericValues',
|
|
'cleanupListOfValues',
|
|
'convertColors',
|
|
'removeUnknownsAndDefaults',
|
|
'removeNonInheritableGroupAttrs',
|
|
'removeUselessStrokeAndFill',
|
|
'removeViewBox',
|
|
'cleanupEnableBackground',
|
|
'removeHiddenElems',
|
|
'removeEmptyText',
|
|
'convertShapeToPath',
|
|
'moveElemsAttrsToGroup',
|
|
'moveGroupAttrsToElems',
|
|
'collapseGroups',
|
|
'convertPathData',
|
|
'convertTransform',
|
|
'removeEmptyAttrs',
|
|
'removeEmptyContainers',
|
|
'mergePaths',
|
|
'removeUnusedNS',
|
|
'sortAttrs',
|
|
'removeTitle',
|
|
'removeDesc',
|
|
'removeDimensions',
|
|
'removeStyleElement',
|
|
'removeScriptElement'
|
|
]
|
|
})
|
|
.data.replace(/^<svg[^>]*>|<\/svg>$/g, '')
|
|
.replace(/ fill="currentColor"/g, '')
|
|
.replace(/ (clip|fill)-rule="evenodd"/g, '')
|
|
.replace(/\/>/g, ' />')
|