Skip to content

Instantly share code, notes, and snippets.

@cannap
Last active April 5, 2017 13:36
Show Gist options
  • Save cannap/ce91c5b6d957f9c2ef2225dded668a9c to your computer and use it in GitHub Desktop.
Save cannap/ce91c5b6d957f9c2ef2225dded668a9c to your computer and use it in GitHub Desktop.
icons8 to json
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