From a18bd9df35798843e1a721f59466900769599b96 Mon Sep 17 00:00:00 2001
From: taskylizard <75871323+taskylizard@users.noreply.github.com>
Date: Tue, 23 Jan 2024 11:01:50 +0000
Subject: [PATCH] fix(theme): fix emojis
---
.vitepress/config.mts | 36 +++++++++++++++++++++---------------
package.json | 1 +
pnpm-lock.yaml | 9 +++++++++
3 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/.vitepress/config.mts b/.vitepress/config.mts
index 7353e1ea6f..fcfb355a08 100644
--- a/.vitepress/config.mts
+++ b/.vitepress/config.mts
@@ -11,23 +11,28 @@ import { withPwa } from "@vite-pwa/vitepress";
import fg from "fast-glob";
import { resolve } from "node:path";
import { FileSystemIconLoader } from "@iconify/utils/lib/loader/node-loaders";
-import { icons } from "@iconify-json/octicon";
+import { icons as octicon } from "@iconify-json/octicon";
+import { icons as twemoji } from "@iconify-json/twemoji";
-const defs = Object.fromEntries(
- Object.entries(icons.icons).map(([key]) => {
- return [key, ""];
- }),
-);
-
-const shortcuts = Object.fromEntries(
- Object.entries(icons.aliases || {}).map(([key, value]) => {
- return [key, value.parent];
- }),
-);
+const defs = {
+ ...Object.fromEntries(
+ Object.entries(octicon.icons).map(([key]) => {
+ return [`octicon-${key}`, ""];
+ }),
+ ),
+ ...Object.fromEntries(
+ Object.entries(twemoji.icons).map(([key]) => {
+ return [key, ""];
+ }),
+ ),
+};
function emojiRender(md: MarkdownRenderer) {
- md.renderer.rules.emoji = (token, idx) => {
- return ``;
+ md.renderer.rules.emoji = (tokens, idx) => {
+ if (tokens[idx].markup.startsWith("octicon-")) {
+ return ``;
+ }
+ return ``;
};
}
@@ -97,7 +102,7 @@ export default withPwa(
generateImages(context);
},
markdown: {
- emoji: { defs, shortcuts },
+ emoji: { defs },
config(md) {
md.use(emojiRender);
md.use(imgLazyload);
@@ -107,6 +112,7 @@ export default withPwa(
},
},
vite: {
+ optimizeDeps: { exclude: ["workbox-window"] },
plugins: [
UnoCSS({
presets: [
diff --git a/package.json b/package.json
index 451c0ff775..941893c2f2 100644
--- a/package.json
+++ b/package.json
@@ -42,6 +42,7 @@
"@iconify-json/mdi": "^1.1.55",
"@iconify-json/octicon": "^1.1.52",
"@iconify-json/simple-icons": "^1.1.76",
+ "@iconify-json/twemoji": "^1.1.15",
"@iconify/utils": "^2.1.11",
"@types/node": "^20.8.9",
"prettier": "^3.2.1"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d3e024586a..051053ed5e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -88,6 +88,9 @@ devDependencies:
'@iconify-json/simple-icons':
specifier: ^1.1.76
version: 1.1.76
+ '@iconify-json/twemoji':
+ specifier: ^1.1.15
+ version: 1.1.15
'@iconify/utils':
specifier: ^2.1.11
version: 2.1.11
@@ -1998,6 +2001,12 @@ packages:
'@iconify/types': 2.0.0
dev: true
+ /@iconify-json/twemoji@1.1.15:
+ resolution: {integrity: sha512-ze2CAOwIWBKIP6ih6qMDItasVjRicktl2Qr3/ohZSMToAHm9z3Q6HCwE48eT0+D+uFpGBlNRQ22HHyE5izyhDg==}
+ dependencies:
+ '@iconify/types': 2.0.0
+ dev: true
+
/@iconify/types@2.0.0:
resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==}