mirror of
https://ghproxy.net/https://github.com/elementor/elementor-icons.git
synced 2025-10-04 23:07:22 +08:00
Tweak - Creating a JSON file that holds the icons SVG data with each icon name as a key.
This commit is contained in:
parent
5ff53b4213
commit
de94344ffa
2 changed files with 26 additions and 1 deletions
26
Gruntfile.js
26
Gruntfile.js
|
@ -1,3 +1,6 @@
|
|||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
|
||||
module.exports = function( grunt ) {
|
||||
'use strict';
|
||||
|
||||
|
@ -83,9 +86,30 @@ module.exports = function( grunt ) {
|
|||
}
|
||||
} );
|
||||
|
||||
// Generating a JSON file that holds the icons SVG data, with each icon name as a key.
|
||||
grunt.registerTask( 'generate-svg-icons-json', () => {
|
||||
const rootPath = path.resolve( __dirname, './' ),
|
||||
svgIconsJsonPath = path.join( rootPath, 'eicons.json' ),
|
||||
configJsonPath = path.join( rootPath, 'config.json' ),
|
||||
configJsonContent = JSON.parse( fs.readFileSync( configJsonPath ) ),
|
||||
svgIconsJsonContent = {};
|
||||
|
||||
configJsonContent.glyphs.forEach( ( obj ) => {
|
||||
// Currently there are no 'height' values in the config file.
|
||||
if ( ! obj.svg.height ) {
|
||||
obj.svg.height = obj.svg.width;
|
||||
}
|
||||
|
||||
svgIconsJsonContent[ obj.css ] = obj.svg;
|
||||
} );
|
||||
|
||||
fs.writeFileSync( svgIconsJsonPath, JSON.stringify( svgIconsJsonContent ) );
|
||||
} );
|
||||
|
||||
// Default task(s).
|
||||
grunt.registerTask( 'default', [
|
||||
'styles'
|
||||
'styles',
|
||||
'generate-svg-icons-json'
|
||||
] );
|
||||
|
||||
grunt.registerTask( 'styles', [
|
||||
|
|
1
eicons.json
Normal file
1
eicons.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue