1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-12-25 15:14:19 +00:00

Generate the preview pages based on the current version

This commit is contained in:
Nathan Downs 2019-07-01 16:58:58 -07:00
parent 3ddfb2ac3b
commit 53ac4682ff
2 changed files with 21 additions and 17 deletions

View File

@ -9,7 +9,7 @@ var fs = require('fs');
var path = require('path');
var { parse } = require('twemoji-parser');
var Utils = require('./utils');
var { version } = require('../package.json');
function file(which) {
return path.join(__dirname, '..', which);
@ -20,21 +20,24 @@ function distFile(...which) {
}
fs.readdir(file('assets/ai'), function (err, files) {
var page = fs.readFileSync(file('src/templates/preview.html')).toString().replace(
'{{emoji-list}}',
'<li>' + files.map(function (filename) {
var codepoints = filename.replace('.ai', '').split('-');
var emoji = codepoints.map(function(codepoint) {
return Utils.fromCodePoint(codepoint);
}).join('');
if (parse(`${emoji}\ufe0f`).length === 1) {
codepoints.push('fe0f');
}
return codepoints.map(function (codepoint) {
return '&#x' + codepoint.toUpperCase() + ';';
}).join('');
}).join('</li>\n <li>')+ '</li>'
);
var page = fs.readFileSync(file('src/templates/preview.html'))
.toString()
.replace(
'{{emoji-list}}',
'<li>' + files.map(function (filename) {
var codepoints = filename.replace('.ai', '').split('-');
var emoji = codepoints.map(function(codepoint) {
return Utils.fromCodePoint(codepoint);
}).join('');
if (parse(`${emoji}\ufe0f`).length === 1) {
codepoints.push('fe0f');
}
return codepoints.map(function (codepoint) {
return '&#x' + codepoint.toUpperCase() + ';';
}).join('');
}).join('</li>\n <li>')+ '</li>'
)
.replace('{{version}}', version);
fs.writeFileSync(
distFile('preview.html'),
page.replace(
@ -43,6 +46,7 @@ fs.readdir(file('assets/ai'), function (err, files) {
size: 72
})
)
);
fs.writeFileSync(
distFile('preview-svg.html'),

View File

@ -25,7 +25,7 @@
vertical-align: -0.1em;
}
</style>
<script src="https://twemoji.maxcdn.com/v/latest/twemoji.min.js" crossorigin="anonymous"></script>
<script src="https://twemoji.maxcdn.com/v/{{version}}/twemoji.min.js" crossorigin="anonymous"></script>
</head>
<body>
<ul class="emoji-list">