Skip to content

Scope data is not being converted into corresponding values #154

@kamal-choudhary

Description

@kamal-choudhary

Hi, thank you so much for the awesome package.

I am practicing with the very basic example that is there in the README file.

Here is the code I am using:

import { serialize } from "next-mdx-remote/serialize";
import { MDXRemote } from "next-mdx-remote";

const data = { product: "next" };

export default function TestPage({ source }) {
  console.log("source object received", source);
  return (
    <div className="wrapper">
      <MDXRemote {...source} />
    </div>
  );
}

export async function getStaticProps() {
  const source = "Some **mdx** text with some data: {product}";
  const mdxSource = await serialize(source, { scope: data });
  return { props: { source: mdxSource } };
}

The problem is that the "product" variable is not being converted into its corresponding value i.e. "next". I am getting the exact same string on the front end.

This is what is rendered on screen: "Some mdx text with some data: {product}"

Although when I see the result of the console statement, the scope object is there and it does contain the value of "product".

P.S. I am relatively new to NextJS and English is also not my first language. Please pardon me if this is a noob's question.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions