mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
⚙️ fix: resolve duplicate id display issue
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user