feat: use syntax highlight assets on server

This commit is contained in:
sup39 2024-01-25 07:29:26 +09:00
parent 4f061a2849
commit 1198f5c50e
Signed by: sup39
GPG key ID: 111C00916C1641E5
2 changed files with 4 additions and 5 deletions

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 "prismjs/plugins/autoloader/prism-autoloader.js";
import { defaultStore } from "@/store"; import { defaultStore } from "@/store";
// TODO Prism.plugins.autoloader.languages_path = defaultStore.state.useEmojiCdn
Prism.plugins.autoloader.languages_path = ? "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/"
"https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/"; : "/client-assets/prismjs/components/";
const nonExistingLanguagesCache = new Set<string>(); const nonExistingLanguagesCache = new Set<string>();
export const loadLanguage = (lang: string) => export const loadLanguage = (lang: string) =>
new Promise<void>((resolve, reject) => { new Promise<void>((resolve, reject) => {
// for now
if (!defaultStore.state.useEmojiCdn) return reject();
// cached non-existing language // cached non-existing language
if (nonExistingLanguagesCache.has(lang)) return reject(); if (nonExistingLanguagesCache.has(lang)) return reject();
// load language with autoloader // load language with autoloader