mirror of
https://github.com/pheralb/svgl.git
synced 2025-02-05 22:48:17 +08:00
🎨 New light/dark theme for Shiki
This commit is contained in:
parent
4bceb2137c
commit
b29dfd8332
@ -72,3 +72,12 @@
|
|||||||
src: url('/fonts/GeistMonoVariableVF.woff2') format('woff2');
|
src: url('/fonts/GeistMonoVariableVF.woff2') format('woff2');
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html.dark .shiki,
|
||||||
|
html.dark .shiki span {
|
||||||
|
color: var(--shiki-dark) !important;
|
||||||
|
background-color: transparent !important;
|
||||||
|
font-style: var(--shiki-dark-font-style) !important;
|
||||||
|
font-weight: var(--shiki-dark-font-weight) !important;
|
||||||
|
text-decoration: var(--shiki-dark-text-decoration) !important;
|
||||||
|
}
|
||||||
|
@ -36,11 +36,19 @@ const mdsvexOptions = {
|
|||||||
highlight: {
|
highlight: {
|
||||||
highlighter: async (code, lang = 'text') => {
|
highlighter: async (code, lang = 'text') => {
|
||||||
const highlighter = await getHighlighter({
|
const highlighter = await getHighlighter({
|
||||||
themes: ['vesper'],
|
themes: ['github-light', 'github-dark'],
|
||||||
langs: ['javascript', 'typescript', 'bash', 'json']
|
langs: ['javascript', 'typescript', 'bash', 'json']
|
||||||
});
|
});
|
||||||
await highlighter.loadLanguage('javascript', 'typescript', 'bash');
|
await highlighter.loadLanguage('javascript', 'typescript', 'bash');
|
||||||
const html = escapeSvelte(highlighter.codeToHtml(code, { lang, theme: 'vesper' }));
|
const html = escapeSvelte(
|
||||||
|
highlighter.codeToHtml(code, {
|
||||||
|
lang,
|
||||||
|
themes: {
|
||||||
|
light: 'github-light',
|
||||||
|
dark: 'github-dark'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
return `{@html \`${html}\` }`;
|
return `{@html \`${html}\` }`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user