feat: use syntax highlight assets on server #14

Manually merged
sup39 merged 1 commit from feat/prism-local-assets into main 2024-01-25 12:37:04 +09:00
2 changed files with 4 additions and 5 deletions
Showing only changes of commit 1198f5c50e - Show all commits

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