hippofish/packages/client/src/scripts/twemoji-base.ts
ThatOneCalculator 73cf3b64e5
refactor: 🔥 remove local twemoji in backend assets, replace with @discordapp/twemoji
They ended up publishing svg in dist
2023-12-06 11:11:42 -08:00

16 lines
567 B
TypeScript

import { defaultStore } from "@/store";
export const twemojiSvgBase = defaultStore.state.useEmojiCdn
? "https://cdn.jsdelivr.net/gh/discord/twemoji@latest/assets/svg"
: "/twemoji";
export function char2fileName(char: string): string {
let codes = Array.from(char).map((x) => x.codePointAt(0)?.toString(16));
if (!codes.includes("200d")) codes = codes.filter((x) => x !== "fe0f");
codes = codes.filter((x) => x?.length);
return codes.join("-");
}
export function char2filePath(char: string): string {
return `${twemojiSvgBase}/${char2fileName(char)}.svg`;
}