Where to add the rehype plugin ? #946
-
As told in this, do I have to add this https://fumadocs.vercel.app/docs/headless/mdx/rehype-code#usage. import { defineDocs, defineConfig } from 'fumadocs-mdx/config';
import rehypeKatex from 'rehype-katex';
import remarkMath from 'remark-math';
import { rehypeCode } from 'fumadocs-core/mdx-plugins';
export const { docs, meta } = defineDocs(
{
docs: {
dir: 'content/learn'
},
meta: {
dir: 'content/learn'
}
}
);
export default defineConfig({
mdxOptions: {
remarkPlugins: [remarkMath],
rehypePlugins: (v) => [rehypeKatex, rehypeCode, ...v],
},
}); But it is not working, I have installed shiki and referred to the docs and they look way more complicated than this. Any solution ? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
Rehype code is added by default, you don't need any configuration to enable syntax highlighting |
Beta Was this translation helpful? Give feedback.
-
I think it is having some error then, this is how I want the code block to look like (neglect the errors) |
Beta Was this translation helpful? Give feedback.
-
Yes, we don't have a default font, it's up to you |
Beta Was this translation helpful? Give feedback.
-
it worked, I just did some minor changes to the import { defineDocs, defineConfig } from "fumadocs-mdx/config";
import rehypeKatex from "rehype-katex";
import remarkMath from "remark-math";
export const { docs, meta } = defineDocs({
docs: {
dir: "content/learn",
},
meta: {
dir: "content/learn",
},
});
export default defineConfig({
mdxOptions: {
rehypeCodeOptions: {
langs: ["python", "javascript", "typescript"],
themes: {
light: "light-plus",
dark: "slack-dark",
},
},
remarkPlugins: [remarkMath],
rehypePlugins: (v) => [rehypeKatex, ...v],
},
});
``` should I add this in the syntax highlighting or shiki component ? |
Beta Was this translation helpful? Give feedback.
The
rehypeCodeOptions
is what you need, it offers the same options as Shiki's rehype integration + some of our own features(note: with global config, you use
defineConfig
's mdx option instead ofgetDefaultMDXOptions
)