mirror of
https://github.com/iconify/iconify.git
synced 2024-11-09 23:00:56 +00:00
chore: add transform
callback on getCustomIcon
This commit is contained in:
parent
5cab683047
commit
5cb43cc2d2
@ -1,3 +1,4 @@
|
||||
import type { Awaitable } from '@antfu/utils';
|
||||
import createDebugger from 'debug';
|
||||
import type { CustomIconLoader, InlineCollection } from './types';
|
||||
|
||||
@ -7,7 +8,7 @@ export async function getCustomIcon(
|
||||
custom: CustomIconLoader | InlineCollection,
|
||||
collection: string,
|
||||
icon: string,
|
||||
scale = 1
|
||||
transform?: (svg: string) => Awaitable<string>
|
||||
): Promise<string | undefined> {
|
||||
let result: string | undefined | null;
|
||||
|
||||
@ -27,6 +28,6 @@ export async function getCustomIcon(
|
||||
if (!result.startsWith('<svg ')) {
|
||||
console.warn(`Custom icon "${icon}" in "${collection}" is not a valid SVG`);
|
||||
}
|
||||
return result.replace('<svg ', `<svg height="${scale}em" width="${scale}em" `);
|
||||
return transform ? await transform(result) : result
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user