mirror of
https://github.com/iconify/iconify.git
synced 2024-12-12 21:57:50 +00:00
feat(next): split modern loader for node and browser support
This commit is contained in:
parent
65dfecf963
commit
062a852a79
@ -2,6 +2,7 @@ import type { Awaitable } from '@antfu/utils';
|
||||
import { promises as fs, Stats } from 'fs';
|
||||
import type { CustomIconLoader } from './types';
|
||||
import { camelize, pascalize } from '../misc/strings';
|
||||
import { isNode } from './loader';
|
||||
|
||||
/**
|
||||
* Returns CustomIconLoader for loading icons from a directory
|
||||
@ -10,7 +11,8 @@ export function FileSystemIconLoader(
|
||||
dir: string,
|
||||
transform?: (svg: string) => Awaitable<string>
|
||||
): CustomIconLoader {
|
||||
return async (name) => {
|
||||
return isNode
|
||||
? async (name) => {
|
||||
const paths = [
|
||||
`${dir}/${name}.svg`,
|
||||
`${dir}/${camelize(name)}.svg`,
|
||||
@ -30,5 +32,5 @@ export function FileSystemIconLoader(
|
||||
: svg;
|
||||
}
|
||||
}
|
||||
};
|
||||
} : () => undefined;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user