hikerpig / foam-template-gatsby-kb

A Foam/Obsidian template using gatsby-theme-kb for publishing your knowledge base
https://foam-template-gatsby-kb.hikerpig.vercel.app
62 stars 13 forks source link

How to add gatsby-remark-katex? #7

Closed timothywangdev closed 3 years ago

timothywangdev commented 3 years ago

I'd like to render math equations with katex and I wonder where I should put the gatsby-remark-katex plugin? Thanks!

hikerpig commented 3 years ago

@timothywangdev At first I think it's pretty easy to add something to defaultPluginMdx just like other gatsby remark plugins in _layouts/gatsby-config.js. But then I found there is an upstream problem of gatsby-remark-katex Doesn’t work with gatsby-plugin-mdx.

I tried some of the configs posted in the answers and no luck 😞. Maybe we can track the issue and wait for the day that we can solve this simply by upgrading some dependencies.

flashshare commented 3 years ago

Any updates for gatsby-remark-katex? Maybe we can try with remark-math and rehype-katex

hikerpig commented 3 years ago

@flashshare I don't know if things have changed since last time I checked. Maybe I will find sometime to look at it this week.

flashshare commented 3 years ago

@hikerpig These plugins work for me

{
  resolve: "gatsby-plugin-mdx",
  options: {
    remarkPlugins: [require("remark-math")],
    rehypePlugins: [require("rehype-katex")],
  },
},

plugins version

"rehype-katex": "^5.0.0",
"remark": "^12.0.1",
"remark-math": "^3.0.1"
hikerpig commented 3 years ago

@timothywangdev I've pushed a new commit to support math notation. The demo can be viewed in https://hikerpig.github.io/foam-template-gatsby-kb/math

flashshare commented 3 years ago

@hikerpig Great! This theme is indeed good. I hope it will be popular soon. Not only for foam users, but also for Obsidian users