mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-18 05:17:43 +01:00
* add configs
* Add vue components
* Add documentation
* add alpha release version
* improve npm ignore files
* add tests
* Make style and class attrs work
* 📦 bump version
* Add Icon suffix for component names
* bump version
* Add icon component example
* remove space
* add new build strategy
* Write a better intro
* add other node design
* fix
* add new default template
* add tempalte
* improve code
* small improvements
* small improvements
* move files
* Connect lucide with lucide-react
* Add support for vue
* Add licenses to packages
* Fix tests
* refactor build scripts
* Minor code fixes
* update homepage readme
* Update footer text
* Add a better introduction to packages
* Split up in tempaltes
* Add new types build file
* Setup workflow file
* update readme
* update
* Fix build
* remove debug code
* Add check if svgs have duplicated children
* Add check if their are no children
* small fixes
* last fixes in the build
* Move script to packages folder
* Fix tests and add types for lucide
* Add rule to package.json
* add types in build
* add npm ignore
* update package.jsons
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
/* eslint-disable import/no-extraneous-dependencies */
|
|
import { basename } from 'path';
|
|
import { parseSync } from 'svgson';
|
|
import { generateHashedKey, readSvg, hasDuplicatedChildren } from '../helpers';
|
|
|
|
/**
|
|
* Build an object in the format: `{ <name>: <contents> }`.
|
|
* @param {string[]} svgFiles - A list of filenames.
|
|
* @param {Function} getSvg - A function that returns the contents of an SVG file given a filename.
|
|
* @returns {Object}
|
|
*/
|
|
export default (svgFiles, iconsDirectory, renderUniqueKey = false) =>
|
|
svgFiles
|
|
.map(svgFile => {
|
|
const name = basename(svgFile, '.svg');
|
|
const svg = readSvg(svgFile, iconsDirectory);
|
|
const contents = parseSync(svg);
|
|
|
|
if (!(contents.children && contents.children.length)) {
|
|
throw new Error(`${name}.svg has no children!`);
|
|
}
|
|
|
|
if (hasDuplicatedChildren(contents.children)) {
|
|
throw new Error(`Duplicated children in ${name}.svg`);
|
|
}
|
|
|
|
if (renderUniqueKey) {
|
|
contents.children = contents.children.map(child => {
|
|
child.attributes.key = generateHashedKey(child);
|
|
|
|
return child;
|
|
});
|
|
}
|
|
|
|
return { name, contents };
|
|
})
|
|
.reduce((icons, icon) => {
|
|
icons[icon.name] = icon.contents;
|
|
return icons;
|
|
}, {});
|