Skip to content

Commit

Permalink
Change emoji data from default to named export
Browse files Browse the repository at this point in the history
  • Loading branch information
jhildenbiddle committed Mar 4, 2022
1 parent d52b476 commit 3f2dd46
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion build/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ function writeEmojiJS(emojiData) {
const emojiJS =
fs.existsSync(filePaths.emojiJS) &&
fs.readFileSync(filePaths.emojiJS, 'utf8');
const newEmojiJS = `export default ${JSON.stringify(emojiData, {}, 2)}`;
const newEmojiJS = `export const emojifyData = ${JSON.stringify(
emojiData,
{},
2
)}`;

if (!emojiJS || emojiJS !== newEmojiJS) {
fs.writeFileSync(filePaths.emojiJS, newEmojiJS);
Expand Down
2 changes: 1 addition & 1 deletion src/core/render/emojify-data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const emojifyData = {
baseURL: 'https://github.githubassets.com/images/icons/emoji/',
data: {
100: 'unicode/1f4af.png?v8',
Expand Down
6 changes: 3 additions & 3 deletions src/core/render/emojify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import emojiData from './emojify-data.js';
import { emojifyData } from './emojify-data.js';

function replaceEmojiShorthand(m, $1, useNativeEmoji) {
const emojiMatch = emojiData.data[$1];
const emojiMatch = emojifyData.data[$1];

let result = m;

Expand All @@ -18,7 +18,7 @@ function replaceEmojiShorthand(m, $1, useNativeEmoji) {
.concat('︎');
result = `<span class="emoji">${emojiUnicode}</span>`;
} else {
result = `<img src="${emojiData.baseURL}${emojiMatch}.png" alt="${$1}" class="emoji" loading="lazy">`;
result = `<img src="${emojifyData.baseURL}${emojiMatch}.png" alt="${$1}" class="emoji" loading="lazy">`;
}
}

Expand Down

0 comments on commit 3f2dd46

Please sign in to comment.