directory


目录

title: Importing SVG from directory
types:
  SVG: '../svg/index.md'
  IconSet: '../icon-set/index.md'
functions:
  cleanupSVG: '../icon/cleanup.md'
  parseColors: '../icon/colors.md'
  runSVGO: '../icon/svgo.md'

Importing SVG from directory

This function is part of import functions in Iconify Tools.

Functions [func]importDirectory() and [func]importDirectorySync() find and import all SVG files from a directory.

Both functions are identical, the only difference is in how they read files. Function [func]importDirectorySync() reads files synchronously, [func]importDirectory() reads files asynchronously.

Functions create [type]IconSet instance, which can be exported to various formats.

Usage

Function has the following parameters:

Function returns [type]IconSet instance.

Options

The [prop]options object has the following optional properties:

Keyword callback can be asynchronous in [func]importDirectory(), but must be synchronous in [func]importDirectorySync(). It has 3 parameters: file name, default generated keyword, icon set. It should return [type]string with keyword or [type]undefined if file should be skipped.

Validation

After importing icons, they need to be:

See example below.

Examples

Asynchronous example:

src: libraries/tools/import/dir.ts
title: 'example.ts'

Synchronous example:

src: libraries/tools/import/dir-sync.ts
title: 'example.ts'

版本号 #2
由 壳壳虫 创建于 2026-10-31 14:26:00 UTC
由 壳壳虫 更新于 2026-10-31 14:26:01 UTC