Notes on enginering leadership and software development.

Contentlayer supports markdown and even MDX formatting in the frontmatter fields of your documents, as long as you specify the field type as mdx or markdown.

The tricky part is that:

  • markdown fields give you raw HTML code. You'd have to wrap it in __dangerouslySetHTML or something.
  • mdx gives you the code that you have to pass into useMDXComponent to render.
  • Either way, you have to decide where to allow markdown formatting and where to strip it.

I've just implemented it for the blog here:

  • Posts lists gets new PostDescription component that renders MDX-processed post description.
  • Post metadata and RSS gets raw description, implemented in a little custom field on Contentlayer that strips formatting.