code-hike / codehike

Marvellous code walkthroughs
https://codehike.org
MIT License
4.39k stars 135 forks source link

Possible to use from within JSX? #257

Closed brianjenkins94 closed 1 year ago

brianjenkins94 commented 1 year ago

Something like this maybe?:

import { CH } from "@code-hike/mdx/components";

export default function Example() {
    return (
        <CH.Code files={[
            `
                python one.py
                print("Hello, one!");
            `,
            `
                python two.py
                print("Hello, two!");
            `
        ]} />
    );
}
pomber commented 1 year ago

Not possible. The remark plugin needs to run (for syntax highlighting and other stuff).

If the code you want to show doesn't change, sometimes you can import the mdx files as if it was another jsx file, and use it anywhere in your React tree.