ShikiCodeBlocks: Update Languages & Themes
This commit is contained in:
parent
2b9a173caa
commit
b8bafa47a9
3 changed files with 24 additions and 12 deletions
|
|
@ -18,11 +18,12 @@
|
|||
|
||||
import { ILanguageRegistration } from "@vap/shiki";
|
||||
|
||||
export const VPC_REPO = "Vap0r1ze/vapcord";
|
||||
export const VPC_REPO_COMMIT = "4d0e4b420fb1e4358852bbd18c804a6f5e54c0d7";
|
||||
export const vpcRepoAssets = `https://raw.githubusercontent.com/${VPC_REPO}/${VPC_REPO_COMMIT}/assets/shiki-codeblocks`;
|
||||
export const vpcRepoGrammar = (fileName: string) => `${vpcRepoAssets}/${fileName}`;
|
||||
export const vpcRepoLanguages = `${vpcRepoAssets}/languages.json`;
|
||||
import { SHIKI_REPO, SHIKI_REPO_COMMIT } from "./themes";
|
||||
|
||||
export const JSON_REPO = "thororen1234/shikijsons";
|
||||
export const JSON_REPO_COMMIT = "f418661f27c3b6b23e5b92156fb77b3e221ef823";
|
||||
export const JSON_URL = `https://raw.githubusercontent.com/${JSON_REPO}/${JSON_REPO_COMMIT}/grammars.json`;
|
||||
export const shikiRepoGrammar = (name: string) => `https://raw.githubusercontent.com/${SHIKI_REPO}/${SHIKI_REPO_COMMIT}/packages/tm-grammars/grammars/${name}.json`;
|
||||
|
||||
export interface Language {
|
||||
name: string;
|
||||
|
|
@ -46,12 +47,17 @@ export interface LanguageJson {
|
|||
export const languages: Record<string, Language> = {};
|
||||
|
||||
export const loadLanguages = async () => {
|
||||
const langsJson: LanguageJson[] = await fetch(vpcRepoLanguages).then(res => res.ok ? res.json() : []);
|
||||
const langsJson = await fetch(JSON_URL).then(res => res.ok ? res.json() : []);
|
||||
const loadedLanguages = Object.fromEntries(
|
||||
langsJson.map(lang => [lang.id, {
|
||||
...lang,
|
||||
grammarUrl: vpcRepoGrammar(lang.fileName),
|
||||
}])
|
||||
langsJson.map(lang => {
|
||||
const { name, displayName, ...rest } = lang;
|
||||
return [name, {
|
||||
...rest,
|
||||
id: name,
|
||||
name: displayName,
|
||||
grammarUrl: shikiRepoGrammar(name),
|
||||
}];
|
||||
})
|
||||
);
|
||||
Object.assign(languages, loadedLanguages);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
import { IShikiTheme } from "@vap/shiki";
|
||||
|
||||
export const SHIKI_REPO = "shikijs/textmate-grammars-themes";
|
||||
export const SHIKI_REPO_COMMIT = "2d87559c7601a928b9f7e0f0dda243d2fb6d4499";
|
||||
export const SHIKI_REPO_COMMIT = "ecd9fb1b4a38381df95048c19cf9b8bdcbb1ec09";
|
||||
export const shikiRepoTheme = (name: string) => `https://raw.githubusercontent.com/${SHIKI_REPO}/${SHIKI_REPO_COMMIT}/packages/tm-themes/themes/${name}.json`;
|
||||
|
||||
export const themes = {
|
||||
|
|
@ -48,6 +48,12 @@ export const themes = {
|
|||
GithubLightDefault: shikiRepoTheme("github-light-default"),
|
||||
GithubLightHighContrast: shikiRepoTheme("github-light-high-contrast"),
|
||||
GithubLight: shikiRepoTheme("github-light"),
|
||||
GruvBoxDarkHard: shikiRepoTheme("gruvbox-dark-hard"),
|
||||
GruvBoxDarkMedium: shikiRepoTheme("gruvbox-dark-medium"),
|
||||
GruvBoxDarkSoft: shikiRepoTheme("gruvbox-dark-soft"),
|
||||
GruvBoxLightHard: shikiRepoTheme("gruvbox-light-hard"),
|
||||
GruvBoxLightMedium: shikiRepoTheme("gruvbox-light-medium"),
|
||||
GruvBoxLightSoft: shikiRepoTheme("gruvbox-light-soft"),
|
||||
Houston: shikiRepoTheme("houston"),
|
||||
KanagawaDragon: shikiRepoTheme("kanagawa-dragon"),
|
||||
KanagawaLotus: shikiRepoTheme("kanagawa-lotus"),
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
@import url("https://cdn.jsdelivr.net/gh/devicons/devicon@v2.10.1/devicon.min.css");
|
||||
@import url("https://cdn.jsdelivr.net/gh/devicons/devicon@v2.17.0/devicon.min.css");
|
||||
Loading…
Add table
Reference in a new issue