From c538c151c7462ad0395ff2c15c5e11e89e362aa8 Mon Sep 17 00:00:00 2001
From: Striven <sg.striven@cutecat.club>
Date: Sat, 04 Apr 2026 19:47:16 +0000
Subject: [PATCH] Initial commit

---
 quartz/util/emoji.ts |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/quartz/util/emoji.ts b/quartz/util/emoji.ts
index e38618d..39f045c 100644
--- a/quartz/util/emoji.ts
+++ b/quartz/util/emoji.ts
@@ -25,14 +25,23 @@
   return r.join("-")
 }
 
-const twemoji = (code: string) =>
-  `https://cdnjs.cloudflare.com/ajax/libs/twemoji/15.1.0/svg/${code.toLowerCase()}.svg`
-const emojiCache: Record<string, Promise<any>> = {}
+type EmojiMap = {
+  codePointToName: Record<string, string>
+  nameToBase64: Record<string, string>
+}
 
-export function loadEmoji(code: string) {
-  const type = "twemoji"
-  const key = type + ":" + code
-  if (key in emojiCache) return emojiCache[key]
+let emojimap: EmojiMap | undefined = undefined
+export async function loadEmoji(code: string) {
+  if (!emojimap) {
+    const data = await import("./emojimap.json")
+    emojimap = data
+  }
 
-  return (emojiCache[key] = fetch(twemoji(code)).then((r) => r.text()))
+  const name = emojimap.codePointToName[`${code.toUpperCase()}`]
+  if (!name) throw new Error(`codepoint ${code} not found in map`)
+
+  const b64 = emojimap.nameToBase64[name]
+  if (!b64) throw new Error(`name ${name} not found in map`)
+
+  return b64
 }

--
Gitblit v1.10.0