Black Sheep Code

I'm going off MDX for blogging

Published:

This blog uses the MDX file format as the source code for the blog posts.

Here is an example code snippet, for this very page (how meta):

At build time, the MDX files then go through a series of transformations.

The rationale for using MDX

The rationale for using MSX is really that I want to use Markdown, but it's nice to be able to put a React component in here and there.

The rationale for using Markdown

I'm a fan of open standards. I'm also a big fan of JSON Schema and OpenAPI.

The main reason is that if you're using an open standard, then you now get a whole wealth of compatable tooling for free.

For example with Markdown we have remark and all of its associated plugins.

Not only do these standard formats allow us to transform the given structure data into something useful, but it also serves as a target for other tools to transform to.

Two entirely seperate tools can thus be compatable by having the standard format as common interchange.

What I'm not liking about MDX - lack of language support in VSCode

Some improvements can be had with the experience by adding the vscode-mdx plugin.

However, I still have these problems:

1. Lack of autocompletion

The plugin does not current support TypeScript, and so properties of a component will no have autocomplete suggestions.

2. Lack of type checking in my IDE.

Similarly, if I missed some mandatory properties, I will not see errors in my IDE. If I reference components that don't exist I will not see errors in my IDE.

3. Lack of type enforcement in my front matter YAML.

The YAML in my front matter has reference to specifc magic strings (eg, tag names, series names).

These are typed freehand, whereas with full typescript support they I could get the autocomplete making it much easier to write them, and not make mistakes.

Conclusions

All this makes me consider whether I'm really getting good value out of MDX.

Especially as I start to add more and more React components, I have to question whether it's much more of a hassle to just be writing straight HTML/JSX.

What do you think, if you're using MDX, are you having these same problems?



Questions? Comments? Criticisms? Get in the comments! 👇

Spotted an error? Edit this page with Github