mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-23 01:09:23 +01:00
lucide-static (#401)
* Add lucide static * add render files * add read scripts * Add sprite generator * start with documentation * Add docs * adding documentation * fix build command * Add some extra static files * bump version * Update packages/lucide-static/README.md Co-authored-by: Kathryn Reeve <67553+BinaryKitten@users.noreply.github.com> * Fix sprite generation * update readme * Add lucide static workflow * adjust readme * Add font to release yml * Temporary turn of new versioning for lucide-static Co-authored-by: Kathryn Reeve <67553+BinaryKitten@users.noreply.github.com>
This commit is contained in:
39
packages/lucide-static/scripts/generateSprite.js
Normal file
39
packages/lucide-static/scripts/generateSprite.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import { stringify } from 'svgson';
|
||||
import { format } from 'prettier';
|
||||
import { appendFile } from '../../../scripts/helpers';
|
||||
|
||||
export default function generateSprite(svgs, packageDir) {
|
||||
const symbols = svgs.map(({ name, parsedSvg }) => ({
|
||||
name: 'symbol',
|
||||
type: 'element',
|
||||
attributes: {
|
||||
id: name,
|
||||
},
|
||||
children: parsedSvg.children,
|
||||
}));
|
||||
|
||||
const spriteSvgObject = {
|
||||
name: 'svg',
|
||||
type: 'element',
|
||||
attributes: {
|
||||
xmlns: 'http://www.w3.org/2000/svg',
|
||||
version: '1.1',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'defs',
|
||||
type: 'element',
|
||||
children: symbols,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const spriteSvg = stringify(spriteSvgObject);
|
||||
const prettifiedSprite = format(spriteSvg, { parser: 'babel' }).replace(/;/g, '');
|
||||
|
||||
const xmlMeta = `<?xml version="1.0" encoding="utf-8"?>\n`;
|
||||
|
||||
appendFile(xmlMeta, `sprite.svg`, packageDir);
|
||||
appendFile(prettifiedSprite, `sprite.svg`, packageDir);
|
||||
}
|
||||
Reference in New Issue
Block a user