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

migrate to mdx #35

Merged
merged 15 commits into from
Mar 17, 2021
Merged

migrate to mdx #35

merged 15 commits into from
Mar 17, 2021

Conversation

yujinyan
Copy link
Owner

@yujinyan yujinyan commented Mar 12, 2021

  • fix toc
  • fix page style
  • smallcaps should not process code blocks
  • hide lc posts from main posts bottom nav

I ran into many issues with gatsby remark plugins when migrating to gatsby-plugin-mdx. Issues and solutions are recorded below.

gatsby-remark-autolink-headers

The plugin injected some style into <head/>. Somehow it is missing with mdx. I am copy pasting the style in global.css.

toc

gatsby-plugin-mdx exposes data structure as toc, which is better than gatsby remark's plain html version.

I reworked the toc implementation based on this blog post.

https://www.bram.us/2020/01/10/smooth-scrolling-sticky-scrollspy-navigation/

The scroll spy logic is encapsulated in scroll-spy-hook.js

small cap

With gatsby-remark-smallcaps, the page appears to render correctly in the browser, but there is error in the browser console.

image

image

To solve this issue, I rewrote gatsby-remark-smallcaps as a rehype plugin.

Useful resources to start with writing rehype plugins:

Remaining issue:

image

katex

gatsby-remark-katex doesn't seem to work with gatsby-plugin-mdx.

I used solution from the following issue comment and it worked.

gatsbyjs/gatsby#20538 (comment)

remarkPlugins: [require(`remark-math`), require("remark-html-katex"),],
gatsbyRemarkPlugins: [
{
  resolve: `gatsby-remark-katex`,
    options: { strict: `ignore`, },
  },
]
"gatsby-remark-katex": "^3.0.0"
"remark-math": "^4.0.0"
"remark-html-katex": "^3.0.0"
"katex": "^0.10.0"

Note that:

  • must use gatsby-remark-katext@^3.0.0, version 4 does not work.

@vercel
Copy link

vercel bot commented Mar 12, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/yujinyan/blog/D75PRU1V1ZayYEGbdn2gGiGnCNWQ
✅ Preview: https://blog-git-mdx-2-yujinyan.vercel.app

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

Successfully merging this pull request may close these issues.

1 participant