ホーム > Gatsby > 【Gatsby.js】How to Fix Missing Tables After Switching to MDX
Gatsby

【Gatsby.js】How to Fix Missing Tables After Switching to MDX

Thank you for your continued support.
This article contains advertisements that help fund our operations.

This article explains how to fix the issue where tables do not appear after switching from MD to MDX in Gatsby.js.

Plugins

  • gatsby-plugin-mdx
  • remark-gfm

Possible Cause

There was an incorrect configuration in the config file.

Additionally, certain plugin versions may not work properly.

Downgrading remark-gfm

I was originally using version 4, but encountered the following error:

Cannot set properties of undefined (setting 'inTable')

To fix this, I downgraded to version 3.0.1 with:

npm install remark-gfm@3.0.1 --save

Changing gatsby.config.js to gatsby.config.mjs

Since I needed to use import in the config file, I renamed it to gatsby.config.mjs and updated the existing code accordingly.

The only major change was replacing:

module.exports = {

with:

export default {

This allowed the use of import, so I added the plugin as follows:

gatsby.config.mjs

import remarkGfm from "remark-gfm"

//~~~~~~

{
  resolve: `gatsby-plugin-mdx`,
  options: {
    mdxOptions: {
      remarkPlugins: [remarkGfm], // Added
    },
    extensions: [`.mdx`, `.md`],
    gatsbyRemarkPlugins: [
      // Omitted
  },
}

Conclusion

This was the solution that worked for me.

I hope this helps someone facing the same issue.

I originally thought it would be simple to build a database using Markdown, retrieve data from Markdown files, and display it on a page. However, it ended up taking too much time, and I now regret not just creating the page in pages using JavaScript from the start. Such is my spring day (cloudy) reflection.

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!