What is exactly required to have icons displayed for code blocks? #596
Answered
by
kyrylolvov
kyrylolvov
asked this question in
Q&A
-
I am currently trying to implement it so icons are rendered near the file name. This is my config import { rehypeCodeDefaultOptions } from "fumadocs-core/mdx-plugins";
import createMDX from "fumadocs-mdx/config";
import { transformerTwoslash } from "fumadocs-twoslash";
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
async redirects() {
return [{ source: "/", destination: "/docs", permanent: true }];
},
};
const withMDX = createMDX({
rootContentPath: "./src/content",
mdxOptions: {
rehypeCodeOptions: {
themes: {
light: "catppuccin-latte",
dark: "catppuccin-mocha",
},
transformers: [...rehypeCodeDefaultOptions.transformers, transformerTwoslash()],
},
},
});
export default withMDX(config); And how I write the code blocks ```js title="config.js"
console.log('js');
``` |
Beta Was this translation helpful? Give feedback.
Answered by
kyrylolvov
Jul 13, 2024
Replies: 2 comments 2 replies
-
Make sure to update to the latest versions |
Beta Was this translation helpful? Give feedback.
0 replies
-
@fuma-nama "fumadocs-core": "^12.4.2",
"fumadocs-mdx": "^8.2.33",
"fumadocs-ui": "^12.4.2", Modified mdx-components export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
defaultComponents,
pre: ({ title, className, icon, allowCopy, ...props }: CodeBlockProps) => (
<CodeBlock title={title} icon={icon} allowCopy={allowCopy}>
<Pre className={cn("max-h-[400px]", className)} {...props} />
</CodeBlock>
),
...components,
};
} And this is my next.config import { rehypeCode, rehypeCodeDefaultOptions } from "fumadocs-core/mdx-plugins";
import createMDX from "fumadocs-mdx/config";
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
async redirects() {
return [{ source: "/", destination: "/docs", permanent: true }];
},
};
const withMDX = createMDX({
rootContentPath: "./src/content",
mdxOptions: {
rehypeCodeOptions: {
themes: {
light: "catppuccin-latte",
dark: "catppuccin-mocha",
},
transformers: [...rehypeCodeDefaultOptions.transformers],
},
rehypePlugins: [[rehypeCode]],
},
});
export default withMDX(config); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason I was passing code component to
<MDX />
. That fixed the issue