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 |   49 +++++++++++++++----------------------------------
 1 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/quartz/util/emoji.ts b/quartz/util/emoji.ts
index 2312943..39f045c 100644
--- a/quartz/util/emoji.ts
+++ b/quartz/util/emoji.ts
@@ -1,10 +1,3 @@
-/**
- * Modified version of https://unpkg.com/twemoji@13.1.0/dist/twemoji.esm.js.
- * Ported from https://github.com/vercel/satori/blob/48aea6f812365959c2888a25261c72ce17992c6d/playground/utils/twemoji.ts.
- */
-
-/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */
-
 const U200D = String.fromCharCode(8205)
 const UFE0Fg = /\uFE0F/g
 
@@ -32,35 +25,23 @@
   return r.join("-")
 }
 
-export const apis = {
-  twemoji: (code: string) =>
-    "https://cdnjs.cloudflare.com/ajax/libs/twemoji/15.1.0/svg/" + code.toLowerCase() + ".svg",
-  openmoji: "https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@3.2.0/svg/",
-  blobmoji: "https://cdn.jsdelivr.net/npm/@svgmoji/blob@3.2.0/svg/",
-  noto: "https://cdn.jsdelivr.net/gh/svgmoji/svgmoji/packages/svgmoji__noto/svg/",
-  fluent: (code: string) =>
-    "https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/" +
-    code.toLowerCase() +
-    "_color.svg",
-  fluentFlat: (code: string) =>
-    "https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/" +
-    code.toLowerCase() +
-    "_flat.svg",
+type EmojiMap = {
+  codePointToName: Record<string, string>
+  nameToBase64: Record<string, string>
 }
 
-const emojiCache: Record<string, Promise<any>> = {}
-
-export function loadEmoji(type: keyof typeof apis, code: string) {
-  const key = type + ":" + code
-  if (key in emojiCache) return emojiCache[key]
-
-  if (!type || !apis[type]) {
-    type = "twemoji"
+let emojimap: EmojiMap | undefined = undefined
+export async function loadEmoji(code: string) {
+  if (!emojimap) {
+    const data = await import("./emojimap.json")
+    emojimap = data
   }
 
-  const api = apis[type]
-  if (typeof api === "function") {
-    return (emojiCache[key] = fetch(api(code)).then((r) => r.text()))
-  }
-  return (emojiCache[key] = fetch(`${api}${code.toUpperCase()}.svg`).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