mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
22 lines
468 B
TypeScript
22 lines
468 B
TypeScript
import { optimize } from 'svgo';
|
|
|
|
export const getPrefixFromSvgUrl = (svgUrl: string) => {
|
|
return svgUrl.split('/').pop()!.replace('.svg', '').split('-').join('_');
|
|
};
|
|
|
|
export const prefixSvgIds = (content: string, prefix: string): string => {
|
|
const result = optimize(content, {
|
|
plugins: [
|
|
{
|
|
name: 'prefixIds',
|
|
params: {
|
|
prefix
|
|
}
|
|
}
|
|
],
|
|
multipass: false
|
|
});
|
|
|
|
return (result as { data: string }).data;
|
|
};
|