shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.91k stars 1.29k forks source link

Rehype Pretty Code Multiple themes not supported #1974

Closed jay3332 closed 1 year ago

jay3332 commented 1 year ago

https://rehype-pretty-code.netlify.app, scroll down to Multiple themes (dark/light mode)

Rehype Pretty Code allows the specification of multiple themes in rehypePrettyCodeOptions, which generates multiple code blocks for every theme allowing for multiple custom themes.

It appears inline code-blocks are correctly handled, however multiline codeblocks only show one of the themes:

Dark theme (correct behavior): image

Light theme (inline code-blocks display properly, however there no light-theme multiline codeblocks are rendered): image

Nextra config:

const withNextra = nextra({
  ...
  mdxOptions: {
    rehypePrettyCodeOptions: {
      theme: {
        dark: JSON.parse(readFileSync('./public/syntax/arctis_dark.json', 'utf-8')),
        light: JSON.parse(readFileSync('./public/syntax/arctis_light.json', 'utf-8')),
      },
      getHighlighter: options => getHighlighter({
        ...options,
        langs: [...]
      })
    }
  },
})
dimaMachina commented 1 year ago

pr welcome

danielmarinq commented 10 months ago

Is there expected support for multiple themes since marking #1992 as completed?

dimaMachina commented 10 months ago

in v2 not, in v3 alpha we need update rehype-pretty-code

dimaMachina commented 9 months ago

@danielmarinq available in https://github.com/shuding/nextra/releases/tag/nextra%403.0.0-alpha.17