code-hike / codehike

Marvellous code walkthroughs
https://codehike.org
MIT License
4.39k stars 135 forks source link

"from" annotation error: "Someone is calling the mdx compile function without setting the path" #327

Closed gaelanmcmillan closed 1 year ago

gaelanmcmillan commented 1 year ago

Background

I have a static Next.js website that renders .mdx files into coding problem editorials. To date, I have been putting the code for each page directly inside the .mdx file, but I read about the from annotation in the CodeHike docs and decided to try importing code into the respective .mdx that way.

Issue

I get the following error when adding a from annotation to my CH.Code code block.

Server Error Error: [next-mdx-remote] error compiling MDX: Code Hike couldn't resolve this annotation: // from ./cribbage-on-steroids.cpp Someone is calling the mdx compile function without setting the path. Open an issue on CodeHike's repo for help.

More information: https://mdxjs.com/docs/troubleshooting-mdx

Info

MDX

This is the code block from my .mdx file:

<CH.Code>
```cpp
// from ./cribbage-on-steroids.cpp
```
</CH.Code>

The .mdx and cribbage-on-steroids.cpp are located in the same directory.

JavaScript

For reference, this is the .../solutions/[slug].js, the file from which pages are statically generated on the site: https://github.com/gaelanmcmillan/more-generic/blob/main/src/pages/solutions/%5Bslug%5D.js


Please let me know if you have any recommendations on resolving this problem! The from annotation seems handy. Thanks.

pomber commented 1 year ago

I think that's a limitation of next-mdx-remote, similar to the way it doesn't support imports.