vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

Support custom attributes such as twoslash for snippets #3823

Open ChronicStone opened 3 weeks ago

ChronicStone commented 3 weeks ago

Is your feature request related to a problem? Please describe.

Currently when you render a code block through a snippet on Vitepress, you don't have a way to append custom attributes, such as twoslash

Describe the solution you'd like

Be able to append custom attributes such as twoslash so that twoslash can be used with snippets as well

Describe alternatives you've considered

I've considered doing a plugin that re-implements the built-in snippet plugin but with that capability, but it feels like this should belong to the built-in plugin.

Maybe it is already the case & I just didn't understand how to do it. I've seen from the docs that this works :

<<< ./.examples/financial-report/data.ts{ts:line-numbers}

But somehow this does not work :

<<< ./.examples/financial-report/data.ts{ts:twoslash}

Additional context

Shiki twoslash : https://shiki.style/packages/twoslash

Validations