Created
February 14, 2024 19:39
-
-
Save horsefacts/06727377d430bb49ebffe7bc3c8603ea to your computer and use it in GitHub Desktop.
Satori Emoji Loading
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
async function loadAdditionalAsset(_code: string, text: string) { | |
if (_code === 'emoji') { | |
const code = getIconCode(text); | |
const version = '14.0.2'; | |
let emojiSvg; | |
try { | |
emojiSvg = await fetch(`https://cdnjs.cloudflare.com/ajax/libs/twemoji/${version}/svg/${code.toLowerCase()}.svg`).text(); | |
} catch (e) { | |
emojiSvg = UNKNOWN_EMOJI_SVG; | |
} | |
return `data:image/svg+xml;base64,${btoa(emojiSvg)}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment