docs icon indicating copy to clipboard operation
docs copied to clipboard

feat: setup twoslash for codeblocks

Open antfu opened this issue 1 year ago • 7 comments

This is working now, but with a few caveats:

Preview

image

Short-term

  • [x] ~~twoslash is not stable yet: https://github.com/twoslashes/twoslash~~
  • [x] ~~Using shikiji's beta https://shikiji.netlify.app/packages/twoslash, which is wait for twoslash~~
  • [x] ~~Once shikiji v0.10 released and VitePress upgrade to it, the pnpm overrides can be removed~~

Long-term

  • __VUE_OPTIONS_API__: true is required at this moment because floating-vue is still using Options API
  • ~~shamefully-hoist=true is required at this moment for twoslash to resolve the types correctly~~

And later we need to revise code blocks across the docs to add the twoslash flag.

antfu avatar Jan 15 '24 16:01 antfu

Deploy Preview for vuejs ready!

Name Link
Latest commit c41715704b4222d1be1eccb7b0955a574f349868
Latest deploy log https://app.netlify.com/sites/vuejs/deploys/65e72cc7e95a7e0008476cf4
Deploy Preview https://deploy-preview-2668--vuejs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Jan 15 '24 16:01 netlify[bot]

I think it's ready now. The only thing is that if we should bring Options API or wait for Floating Vue to adopt to Composition API only

antfu avatar Feb 06 '24 14:02 antfu

@antfu thank you for working on this! Looks great ✨

Could you please resolve the conflicts? I'll merge the PR and add twoslash to the codeblocks

NataliaTepluhina avatar Feb 17 '24 19:02 NataliaTepluhina

I'll release vitepress by tomorrow. It will have shiki@v1. We can remove resolutions from package.json here.

Also, is it possible to use the older code background with twoslash? github-dark's default background doesn't look nice with other stuff.

brc-dd avatar Feb 17 '24 19:02 brc-dd

Let's enable Options API then, it's ok for now until we have a version of floating-vue that is Composition API based.

yyx990803 avatar Mar 05 '24 14:03 yyx990803

Should be good to go now

antfu avatar Mar 05 '24 14:03 antfu

I think we need to be a bit selective on where to use these, let me take a pass on the rest of the docs so it doesn't become distractive.

yyx990803 avatar Mar 05 '24 14:03 yyx990803