feat: use syntax highlight assets on server #14
2 changed files with 4 additions and 5 deletions
1
packages/client/assets/prismjs/components
Symbolic link
1
packages/client/assets/prismjs/components
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../node_modules/prismjs/components
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue