-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to properly use code highlight feature to add additional meta? #193
Comments
If you're referring to syntax highlighting based on coding language, that's done in markdown, not mdc, i.e. you start your blocks with the triple backtick. ```javascript
console.log(…)
``` The rest you can build yourself in a custom component that takes properties for file name, etc., which is what I did. Did I understand your question correctly? |
Thanks for your answer @julie-ng, to better explain what I was referring to, I have this on my source markdown ```js [file.js]
var pic = new Image();
pic.onload = function(); // [!code highlight]
pic.src = 'http://i.imgur.com/hvGAPwJ.png'; //Last
``` And it renders like this on my frontend The language is correctly recognized and highlighted (here is Anyway, neither the filename and the highlighted line are displayed. The filename itself does not seem to be passed as a prop anywhere, while the highlighted lines are given a custom class, but there is not actual styling. I was thinking that the Shiki integration in this module was complete, so I'm not sure if this behavior is wanted or bug. Apparently a custom I can also see that every |
Yes @stefanobartoletti, you need to extend the |
Thanks @robinkloeckner ✌️ |
@stefanobartoletti I have a similar use case, would you be open to sharing how you overwrote that component? Thanks for considering! |
Just like it is explained in the readme, by using a custom prose component via the https://github.com/nuxt-modules/mdc?tab=readme-ov-file#prose-components |
kindly do you consider to show some code? |
I'm trying to set a working shiki configuration and implement some additional meta besides the code itself.
I'd like to be able to render the filename, the language, highlighted lines and possibly a "copy" button, pretty much the features that you can see in many documentation websites, i.e. like Nuxt itself (not nexessariy with this exact layout):
I'm unable to understand how to properly implement this, the readme does not seem to be clear enough on this, and if this is something that should enabled/configured here or not.
I can see that the
ProsePre.vue
component https://github.com/nuxt-modules/mdc/blob/main/src/runtime/components/prose/ProsePre.vue accepts some props likelanguage
,filename
andhighlights
, but it is not obvious if and how it is using them.Can you please explain how to do this? Thanks :)
The text was updated successfully, but these errors were encountered: