Last active
April 5, 2017 13:36
-
-
Save cannap/ce91c5b6d957f9c2ef2225dded668a9c to your computer and use it in GitHub Desktop.
icons8 to json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
var path = require('path') | |
var jsonfile = require('jsonfile') | |
var cheerio = require('cheerio') | |
// Settings | |
var cssFilePath = path.resolve(__dirname, './preview.html') | |
var outputFile = path.resolve(__dirname, './config.json') | |
var $ = cheerio.load(fs.readFileSync(cssFilePath)) | |
jsonfile.spaces = 1 | |
var jsonOutput = { | |
'name': '', | |
'css_prefix_text': 'icons8-', | |
'css_use_suffix': false, | |
'hinting': true, | |
'units_per_em': 1000, | |
'ascent': 850, | |
'glyphs': [] | |
} | |
// | |
$('div[data-name]').each(function () { | |
console.log($(this).data().name); | |
jsonOutput.glyphs.push({css: $(this).data().name}) | |
}) | |
jsonfile.writeFileSync(outputFile, jsonOutput) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment