Closed noam-honig closed 1 week ago
Interesting idea! At first I was thinking this should be solved in userland by creating custom Astro components that simply read the file contents with node:fs
and show them in markdown. But I think as quite many tutorials would benefit from this feature, it would be nice to have it built in TutorialKit.
@AriPerkkio this seems to be built in with vitepres https://vitepress.dev/guide/markdown#import-code-snippets
We already support this feature actually! It's not documented but you can do it with:
```file:/path/to/file.js
```
Let's add documentation for this in https://github.com/stackblitz/tutorialkit/issues/250.
@AriPerkkio the existing solution is only partial - I need the ability to select which lines will be included from the source file.
Sometimes the source file can be 40 lines, with changes to two - I want to focus on 5 lines and highlight the change in these two
Does the collapse
option work there?
\```file:/vite.config.ts showLineNumbers {7-11} collapse={1-4, 13-19}
\```
Sure - that's good enough.
Is there a specific md page you want me to document all of this in?
Hi @AriPerkkio I would like to document these options - can you let me know which package are you using for the code snippets - so I'll investigate their docs? and also which one is being used for markdown?
Is there a specific md page you want me to document all of this in?
I think guides/creating-content
would be a good spot for this.
which package are you using for the code snippets - so I'll investigate their docs? and also which one is being used for markdown?
TutorialKit supports expressive-code
and Astro.
We also have these plugins enabled:
Is your feature request related to a problem?
In many cases the code blocks in my markdown is the same code from the
_files
or_solution
- and keeping it consistent is not idealDescribe the solution you'd like.
I wish I could reference to a a file in the lesson from the code.
Something like