Importing Iconify icon set
This tutorial is part of import functions documentation in Iconify Tools.
There is no special function for importing an icon set because it is redundant. All you have to do is read content from file, parse JSON data and create new IconSet instance.
Example
example.ts
ts
import { promises as fs } from 'fs';
import { IconSet, exportToDirectory } from '@iconify/tools';
import { validateIconSet } from '@iconify/utils';
(async () => {
// Read data, parse JSON
const rawData = JSON.parse(
await fs.readFile('files/arty-animated.json', 'utf8')
);
// Validate icon set (optional step)
const validatedData = validateIconSet(rawData);
// Create new IconSet instance
const iconSet = new IconSet(validatedData);
// Done. Do something with icon set...
// For example, export as SVG files
await exportToDirectory(iconSet, {
target: 'output'
})
})();