oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.02k stars 47 forks source link

Support for .mdx extension #144

Closed dweiger closed 7 months ago

dweiger commented 7 months ago

Hey, would it be a conceivable feature to support .mdx extension in addition to .tsx/.jsx? I am currently using the plugin to create component documentation. I also use mdx for this documentation.

I am currently using the following work around to get the path /myPage rendering mdx:

Folder structure:

pages
 myPage
  _myPage.mdx
   index.tsx

Inside index.tsx I simply export the mdx component:

import  MyPage from "./_myPage.mdx";

export default MyPage;

This works well with @mdx-js/rollup. Nevertheless, in my opinion it would be a great feature to support mdx - if used and set up in the project - as extension. So that the following would be possible:

pages
 myPage.mdx

What do you think about it?

oedotme commented 7 months ago

Hey @dweiger, thanks for the suggestion. Could you please provide a StackBlitz repro with the example you've mentioned with @mdx-js/rollup?

dweiger commented 7 months ago

Hey, thanks for the quick reply. Here I have a StackBlitz repo with the example.

oedotme commented 7 months ago

Hey @dweiger, I've added support for .mdx files at v1.18.2, here's a StackBlitz example and example repo based on the react-router example. It only requires installing and configuring @mdx-js/rollup with Vite.

Please let me know if you encounter any issue, thanks.

dweiger commented 7 months ago

Hey @oedotme, thank you very much. I have already tried it and so far everything looks great! It's great how quickly you took care of it! If I stumble across any issues, I will of course let you know!