1
0
Fork 1
mirror of https://example.com synced 2024-11-22 12:26:38 +09:00

feat: use syntax highlight assets on server

Co-authored-by: naskya <m@naskya.net>
This commit is contained in:
sup39 2024-01-25 09:43:19 +09:00 committed by naskya
parent ae8209a848
commit 8c0a8c86ad
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
3 changed files with 4 additions and 6 deletions

View file

@ -43,7 +43,6 @@
### 細かい変更点
- コードブロックの構文ハイライトの対応言語を強化
- TODO: CDN を利用しない設定でもこれを行えるようにする
- TODO: 本家版にもマージリクエストを出す
- モバイル表示の下部のウィジェットボタンを再読み込みボタンに変更可能に
- スマートフォンでウィジェットは使わないけど再読み込みはたくさんする人はいそう

View file

@ -0,0 +1 @@
../../node_modules/prismjs/components

View file

@ -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<string>();
export const loadLanguage = (lang: string) =>
new Promise<void>((resolve, reject) => {
// for now
if (!defaultStore.state.useEmojiCdn) return reject();
// cached non-existing language
if (nonExistingLanguagesCache.has(lang)) return reject();
// load language with autoloader