3 ms·
I dig this. I use mdx which I like but it doesn't play well with nextjs which I don't like. Is there a way to try this out outside of mdxish.com? How would lib
by rustystump 2y ago
I dig this. I use mdx which I like but it doesn't play well with nextjs which I don't like.
Is there a way to try this out outside of mdxish.com? How would library imports work?
- jasonjmcghee 2y agoAbsolutely! In the repo I included a video where I do exactly that - you can either run a local live server that keeps the output html up to date, or you can do a one-off conversion (a command for each). To import a whole script / library, you can either include it in `scripts` in the configuration at the top, or use a script tag like `<script src="mylib.js"></script>` or similar. To import specific things from a script with exports you just: ```javascript // @run type="module" import { foo } from "./foo.js"; console.log(foo); ``` The @run comment accepts any number of attributes after `// @run` which will be set on the script node. or you can always eject and use inline html if needed. <script type="module"> import { foo } from "./foo.js"; console.log(foo); </script> The drawback is markdown editors, previews, etc. tend to play much more nicely with markdown code blocks. If you decide (or need to) use `type="module"` each script / block is isolated apart from `window`.
- rustystump 2y agoawesome thanks!