Repository navigation
Replies: 2 comments
|
There's no direct passthrough for it, VitePress's The escape hatch that does work is // .vitepress/config.ts
import { createHighlighter } from 'shiki'
export default {
markdown: {
theme: { light: 'github-light', dark: 'github-dark' },
async config(md) {
const highlighter = await createHighlighter({
themes: ['github-light', 'github-dark'],
langs: [], // langs get loaded lazily as needed, or list them explicitly
})
md.renderer.rules.fence = (tokens, idx) => {
const token = tokens[idx]
return highlighter.codeToHtml(token.content, {
lang: token.info.trim() || 'text',
themes: { light: 'github-light', dark: 'github-dark' },
defaultColor: false,
})
}
},
},
}With Worth filing as a feature request too, a |
|
VitePress never emits Checked on vitepress 1.6.4 and on What the source actually doesVitePress does not use The theme defaults to a dual theme — const theme = options.theme ?? { light: 'github-light', dark: 'github-dark' }and ...(typeof theme === 'object' && 'light' in theme && 'dark' in theme
? { themes: theme, defaultColor: false }
: { theme })So with a stock config, a build emits (real output from a scratch <div class="language-js vp-adaptive-theme">…
<pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0">
<code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span>…Note: no inline .dark .vp-code span { color: var(--shiki-dark, inherit); }
html:not(.dark) .vp-code span { color: var(--shiki-light, inherit); }(Confirmed in the bundled The recipe: consume the existing variables with
|
Uh oh!
There was an error while loading. Please reload this page.
Is there an easy way to set Shiki configuration like
defaultColoras a VitePress consumer?All reactions