mirror of
https://github.com/lipis/flag-icons.git
synced 2024-11-24 02:17:29 +01:00
feat: enable prefixIds svgo plugin (#1110)
This commit is contained in:
parent
7ed9083b64
commit
f07a36d31d
@ -3,6 +3,18 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
name: "preset-default",
|
name: "preset-default",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "prefixIds",
|
||||||
|
params: {
|
||||||
|
delim: "-",
|
||||||
|
prefix: (_, info) => {
|
||||||
|
if (info.path != null && info.path.length > 0) {
|
||||||
|
return getBasename(info.path).split(".")[0];
|
||||||
|
}
|
||||||
|
return "prefix";
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"convertStyleToAttrs",
|
"convertStyleToAttrs",
|
||||||
"removeDimensions",
|
"removeDimensions",
|
||||||
"removeScriptElement",
|
"removeScriptElement",
|
||||||
@ -10,3 +22,13 @@ module.exports = {
|
|||||||
"sortAttrs",
|
"sortAttrs",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extract basename from path
|
||||||
|
* @see https://github.com/svg/svgo/blob/main/plugins/prefixIds.js
|
||||||
|
*/
|
||||||
|
const getBasename = (path) => {
|
||||||
|
const matched = path.match(/[/\\]?([^/\\]+)$/);
|
||||||
|
if (matched) return matched[1];
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user