Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not work with mdx-bundle in nexjs #484

Open
ucanme opened this issue Nov 23, 2024 · 2 comments
Open

not work with mdx-bundle in nexjs #484

ucanme opened this issue Nov 23, 2024 · 2 comments

Comments

@ucanme
Copy link

ucanme commented Nov 23, 2024

image

my code

export async function getServerSideProps() {
    // slug
    /** @type {import('codehike/mdx').CodeHikeConfig} */
    const chConfig: import('codehike/mdx').CodeHikeConfig = {
        components: {
            code: 'MyCode',
        },
        syntaxHighlighting: {
            theme: "github-dark",
        },
    }


    // post path
    const currentDirectory = process.cwd()
    const postPath = `${currentDirectory}/posts/hello.mdx`
    const sourceMd =  fs.readFileSync(postPath,"utf8")


    const markdown = await bundleMDX({
        source: sourceMd,
        mdxOptions: function (options) {
            options.remarkPlugins = [
                ...(options.remarkPlugins ?? []),
              [remarkCodeHike,chConfig],
            ];
            options.recmaPlugins = [[recmaCodeHike, chConfig]];
            return options;
    }})

    const { code, frontmatter: metadata } = markdown
    return {
        props: {
            code,
            metadata,
            sourceMd,
        }}
}

error msg

Type error: Type 'Plugin<[(CodeHikeConfig | undefined)?], Root, Root>' is not assignable to type 'Plugin<any[], any, any>'.
  The 'this' types of each signature are incompatible.
    Type 'Processor<undefined, undefined, undefined, undefined, undefined>' is not assignable to type 'Processor<void, Root, void, void>'.
      Types of property 'use' are incompatible.
        Type '{ <Parameters_1 extends unknown[] = [], Input extends string | Node | undefined = undefined, Output = Input>(preset?: Preset | null | undefined): Processor<undefined, undefined, undefined, undefined, undefined>; <Parameters_1 extends unknown[] = [], Input extends string | Node | undefined = undefined, Output = Input...' is not assignable to type '{ <PluginParameters extends any[] = any[], Input = Root, Output = Input>(plugin: Plugin<PluginParameters, Input, Output>, ...settings: PluginParameters | [...]): UsePlugin<...>; <PluginParameters extends any[] = any[], Input = Root, Output = Input>(tuple: [...] | [...]): UsePlugin<...>; (presetOrList: Preset | Plugg...'.
          Types of parameters 'preset' and 'plugin' are incompatible.
            Type 'Plugin<any, any, any>' has no properties in common with type 'Preset'.

  135 |             }
  136 |
> 137 |             options.recmaPlugins = [[recmaCodeHike, chConfig]]
      |                                      ^
  138 |             options.remarkPlugins = [
  139 |                 ...(options.remarkPlugins ?? []),
  140 |                 remarkGfm,

@bdrtsky
Copy link

bdrtsky commented Nov 23, 2024

Are you using Turbopack? Yesterday I've learned Next with --turbopack does not work with remark and rehype plugins 🤦‍♂️ To be honest no idea what to do next, using it without turbo makes dev very painful.

Haven't tried Codehike with it, tho. Searching if it's working with Turbopack or not, and found this issue. Seems like it does not work?

@ucanme
Copy link
Author

ucanme commented Nov 24, 2024

Are you using Turbopack? Yesterday I've learned Next with --turbopack does not work with remark and rehype plugins 🤦‍♂️ To be honest no idea what to do next, using it without turbo makes dev very painful.

Haven't tried Codehike with it, tho. Searching if it's working with Turbopack or not, and found this issue. Seems like it does not work?

i just use mdx-bundle in nextjs not with turbopack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants