Skip to content

mdx-table-of-contents not working with next.js #71

@adamsoffer

Description

@adamsoffer

I'm attempting to use the mdx-table-of-contents package with next.js but when I import the tableOfContents object it's undefined:

import Document , { tableOfContents } from "../../../reference-api.mdx";

Here's what my next.config.js file looks like:

const toc = require("mdx-table-of-contents");
const withMDX = require("@next/mdx")({
  options: {
    remarkPlugins: [toc],
  },
  extension: /\.mdx?$/,
});

module.exports = withMDX({
  pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx", "svg"],
});

Any idea what I'm doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions