How can I handle mdx in rescript-remix?

I am trying to create a static blog using rescript-remix

When routing like this, I can see the mdx contents in route /test, but I don’t know how to import the mdx contents in res-routes.

I want do this Remix | MDX

스크린샷 2022-04-12 오후 10.47.17

Idk how remix works, but reading its documentation, I guess that you can do something like that in your rescript module:

    module PostMdx = {
      @module("./first-post.mdx") external attributes: {..} = "attributes"
      @module("./first-post.mdx") external filename: {..} = "filename"
    }

The generated javascript will be something like:

import * as FirstPostMdx from "./first-post.mdx";

var attributes = FirstPostMdx.attributes;

var filename = FirstPostMdx.filename;

Which is very similar to the original remix example (in JavaScript):


Remix example
Example in ReScript

2 Likes