Last active
March 17, 2017 00:30
-
-
Save MadLittleMods/76abcd7c1f3591ef7012b6afce6ace3f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const fs = require('fs-extra'); | |
const emojiNameToUnicodeVersion = require('emoji-unicode-version'); | |
const emojione = require('emojione'); | |
const emojiMap = require('emojione/emoji.json'); | |
const versionToEmojisMap = { | |
'1.1': [], | |
'3.0': [], | |
'3.2': [], | |
'4.0': [], | |
'4.1': [], | |
'5.1': [], | |
'5.2': [], | |
'6.0': [], | |
'6.1': [], | |
'7.0': [], | |
'8.0': [], | |
'9.0': [] | |
}; | |
Object.keys(emojiMap).forEach((name) => { | |
const version = emojiNameToUnicodeVersion(name); | |
versionToEmojisMap[version] = versionToEmojisMap[version] || []; | |
versionToEmojisMap[version].push(name); | |
}) | |
//console.log(versionToEmojisMap); | |
function generatePageMarkup(content) { | |
return ` | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>The HTML5 Herald</title> | |
</head> | |
<body> | |
${content} | |
<style> | |
body { | |
font-size: 1.5em; | |
} | |
</style> | |
</body> | |
</html> | |
`; | |
} | |
const pageContent = ` | |
${Object.keys(versionToEmojisMap).map((version) => { | |
const emojis = versionToEmojisMap[version]; | |
return ` | |
<section> | |
<h3>${version}</h3> | |
<div> | |
${emojis.map((name) => { | |
const unicode = emojiMap[name].unicode.split('-').map((codePointString) => { | |
const codePoint = parseInt(codePointString, 16); | |
return String.fromCodePoint(codePoint); | |
}).join(''); | |
return `<span title="${name}"> | |
${unicode} | |
</span>`; | |
}).join(' ')} | |
</div> | |
</section> | |
`; | |
}).join('')} | |
`; | |
//console.log(pageMarkup); | |
fs.outputFile('./build/emojis-by-version.html', generatePageMarkup(pageContent)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment