zce / velite

Turns Markdown / MDX, YAML, JSON, or others into app's data layer with Zod schema.
http://velite.js.org
MIT License
466 stars 23 forks source link

How to implement a dark/light theme for code highlighting? #235

Closed carlos-dubon closed 3 hours ago

zce commented 6 days ago

First of all, this is not a problem that Velite needs to consider.

I can provide you with my practice, but of course I think it's best to write it down in a document.

export default defineConfig({
  markdown: { 
    rehypePlugins: [
      rehypePrettyCode,
      {
        theme: {
          name: 'custom',
          colors: {
            foreground: 'var(--pc-foreground, #c8d3f5)',
            focusBorder: 'var(--pc-focus-border, #82aaff)',
            contrastBorder: 'var(--pc-contrast-border, #15151b)',
          }
        }
      }
    ]
  }
})
zce commented 6 days ago

In addition, because Velite does not invade the runtime, it cannot provide a mechanism to select the theme according to the runtime env.