feat: Dark mode #15
|
@ -11,18 +11,31 @@ import { getHighlighter } from 'shiki'
|
||||||
const contentDir = process.env?.CHRYSOBLOG_CONTENT ?? "src/content";
|
const contentDir = process.env?.CHRYSOBLOG_CONTENT ?? "src/content";
|
||||||
|
|
||||||
const langs = [
|
const langs = [
|
||||||
"rust",
|
"javascript",
|
||||||
|
"lean",
|
||||||
|
"lisp",
|
||||||
"nix",
|
"nix",
|
||||||
"python",
|
"python",
|
||||||
"lean",
|
"rust",
|
||||||
"javascript",
|
"toml",
|
||||||
"typescript",
|
"typescript",
|
||||||
|
"yaml",
|
||||||
|
"c",
|
||||||
|
"c++",
|
||||||
|
"sh",
|
||||||
];
|
];
|
||||||
const highlightingThemes = {
|
const highlightingThemes = {
|
||||||
light: 'vitesse-light',
|
light: 'vitesse-light',
|
||||||
dark: 'vitesse-dark',
|
dark: 'vitesse-dark',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const themes = Object.keys(highlightingThemes).map(function(k){ return highlightingThemes[k] });
|
||||||
|
const highlighter = await getHighlighter({
|
||||||
|
themes,
|
||||||
|
langs,
|
||||||
|
})
|
||||||
|
await highlighter.loadLanguage(...langs);
|
||||||
|
|
||||||
/** @type {import('@sveltejs/kit').Config} */
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
||||||
|
@ -40,12 +53,6 @@ const config = {
|
||||||
],
|
],
|
||||||
highlight: {
|
highlight: {
|
||||||
highlighter: async (code, lang = 'text') => {
|
highlighter: async (code, lang = 'text') => {
|
||||||
const themes = Object.keys(highlightingThemes).map(function(k){ return highlightingThemes[k] });
|
|
||||||
const highlighter = await getHighlighter({
|
|
||||||
themes,
|
|
||||||
langs,
|
|
||||||
})
|
|
||||||
await highlighter.loadLanguage(...langs);
|
|
||||||
const html = escapeSvelte(highlighter.codeToHtml(code, {
|
const html = escapeSvelte(highlighter.codeToHtml(code, {
|
||||||
lang,
|
lang,
|
||||||
themes: highlightingThemes,
|
themes: highlightingThemes,
|
||||||
|
|
Loading…
Reference in New Issue