feat: Read highlighter languages from metadata
This commit is contained in:
parent
0d87cea96f
commit
7b900c2993
|
@ -12,5 +12,12 @@
|
||||||
},
|
},
|
||||||
"extra": [
|
"extra": [
|
||||||
{ "route": "/archives", "name": "Archives" }
|
{ "route": "/archives", "name": "Archives" }
|
||||||
]
|
],
|
||||||
|
"markdown": {
|
||||||
|
"highlighterLangs": [
|
||||||
|
"python",
|
||||||
|
"lean",
|
||||||
|
"tex"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,3 +26,7 @@ $$
|
||||||
$$
|
$$
|
||||||
\vec z^{(l+1)} = \mat M\vec z^{(l)} + \vec b
|
\vec z^{(l+1)} = \mat M\vec z^{(l)} + \vec b
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
```tex
|
||||||
|
\\newcommand{\\cirno}{9}
|
||||||
|
```
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||||
import adapter from '@sveltejs/adapter-static';
|
import adapter from '@sveltejs/adapter-static';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
import { mdsvex, escapeSvelte } from 'mdsvex';
|
import { mdsvex, escapeSvelte } from 'mdsvex';
|
||||||
import remarkAlert from './src/lib/markdown.js'
|
import remarkAlert from './src/lib/markdown.js'
|
||||||
|
@ -12,7 +13,9 @@ import remarkMath from 'remark-math'
|
||||||
|
|
||||||
const contentDir = process.env?.CHRYSOBLOG_CONTENT ?? "src/content";
|
const contentDir = process.env?.CHRYSOBLOG_CONTENT ?? "src/content";
|
||||||
|
|
||||||
const langs = [
|
const metadata = await fs.promises.readFile(contentDir + "/metadata.json")
|
||||||
|
.then((file) => JSON.parse(file.toString()));
|
||||||
|
const langs = metadata?.markdown.highlighterLangs ?? [
|
||||||
"javascript",
|
"javascript",
|
||||||
"lean",
|
"lean",
|
||||||
"lisp",
|
"lisp",
|
||||||
|
@ -26,11 +29,7 @@ const langs = [
|
||||||
"c++",
|
"c++",
|
||||||
"sh",
|
"sh",
|
||||||
];
|
];
|
||||||
const highlightingThemes = {
|
const katexOptions = metadata?.markdown.katex ?? {
|
||||||
light: 'vitesse-light',
|
|
||||||
dark: 'vitesse-dark',
|
|
||||||
};
|
|
||||||
const katexOptions = {
|
|
||||||
macros: {
|
macros: {
|
||||||
"\\Nat": "\\mathbb N",
|
"\\Nat": "\\mathbb N",
|
||||||
"\\Complex": "\\mathbb C",
|
"\\Complex": "\\mathbb C",
|
||||||
|
@ -39,6 +38,10 @@ const katexOptions = {
|
||||||
"\\rv": "\\mathrm",
|
"\\rv": "\\mathrm",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
const highlightingThemes = {
|
||||||
|
light: 'vitesse-light',
|
||||||
|
dark: 'vitesse-dark',
|
||||||
|
};
|
||||||
|
|
||||||
const themes = Object.keys(highlightingThemes).map(function(k){ return highlightingThemes[k] });
|
const themes = Object.keys(highlightingThemes).map(function(k){ return highlightingThemes[k] });
|
||||||
const highlighter = await getHighlighter({
|
const highlighter = await getHighlighter({
|
||||||
|
|
Loading…
Reference in New Issue