From 1198f5c50efd753c3cbc9f31a2edcfe0549f061e Mon Sep 17 00:00:00 2001 From: sup39 Date: Thu, 25 Jan 2024 07:29:26 +0900 Subject: [PATCH] feat: use syntax highlight assets on server --- packages/client/assets/prismjs/components | 1 + packages/client/src/scripts/prism.ts | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 120000 packages/client/assets/prismjs/components diff --git a/packages/client/assets/prismjs/components b/packages/client/assets/prismjs/components new file mode 120000 index 00000000..e54cd377 --- /dev/null +++ b/packages/client/assets/prismjs/components @@ -0,0 +1 @@ +../../node_modules/prismjs/components \ No newline at end of file diff --git a/packages/client/src/scripts/prism.ts b/packages/client/src/scripts/prism.ts index 0b102359..ad1a5ea0 100644 --- a/packages/client/src/scripts/prism.ts +++ b/packages/client/src/scripts/prism.ts @@ -2,15 +2,13 @@ import Prism from "prismjs"; import "prismjs/plugins/autoloader/prism-autoloader.js"; import { defaultStore } from "@/store"; -// TODO -Prism.plugins.autoloader.languages_path = - "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/"; +Prism.plugins.autoloader.languages_path = defaultStore.state.useEmojiCdn + ? "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/" + : "/client-assets/prismjs/components/"; const nonExistingLanguagesCache = new Set(); export const loadLanguage = (lang: string) => new Promise((resolve, reject) => { - // for now - if (!defaultStore.state.useEmojiCdn) return reject(); // cached non-existing language if (nonExistingLanguagesCache.has(lang)) return reject(); // load language with autoloader