code-hike / codehike

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

Allow import of external files with from-annotation #410

Open RichardJECooke opened 8 months ago

RichardJECooke commented 8 months ago

I read https://codehike.org/docs/annotations#from-annotation and then tried:

'''js React.js
# from https://raw.githubusercontent.com/facebook/react/main/scripts/flow/runFlow.js
'''

but it does nothing. Being able to link to external code files, rather than copying and pasting code into all our documentation is important. Especially since code changes frequently.

Is there any workaround, like writing a short component in Nextra to import the code then pass it to Code Hike, possible please?

pomber commented 7 months ago

Hi, check the comment syntax, the example is for python, for js you should use:

```js
// from https://raw.githubusercontent.com/facebook/react/main/scripts/flow/runFlow.js