Skip to content

#51 Twoslash vue support#52

Merged
Adammatthiesen merged 4 commits intowithstudiocms:mainfrom
ackzell:twoslash-vue-support
Feb 12, 2026
Merged

#51 Twoslash vue support#52
Adammatthiesen merged 4 commits intowithstudiocms:mainfrom
ackzell:twoslash-vue-support

Conversation

@ackzell
Copy link
Contributor

@ackzell ackzell commented Jan 24, 2026

Description

My take on #51. I decided to give it a shot myself by following the comments you shared in the issue.

I also added a docs page, not sure if that would be the best place, but better than nothing I guess 😅

@changeset-bot
Copy link

changeset-bot bot commented Jan 24, 2026

🦋 Changeset detected

Latest commit: fd96b32

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
expressive-code-twoslash Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Jan 24, 2026

Deploy Preview for expressive-code-twoslash ready!

Name Link
🔨 Latest commit fd96b32
🔍 Latest deploy log https://app.netlify.com/projects/expressive-code-twoslash/deploys/697606c64e3ed100085697d0
😎 Deploy Preview https://deploy-preview-52--expressive-code-twoslash.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 project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 25, 2026

Open in StackBlitz

npm i https://pkg.pr.new/expressive-code-twoslash@52

commit: fd96b32

Copy link
Member

@Adammatthiesen Adammatthiesen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the simplicity overall, only one nit-pick

Comment on lines 135 to 136
const isVue = codeBlock.language === 'vue';
const selectedTwoslasher = isVue ? twoslasherVue : twoslasher;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the concept of everything going on here... but i almost wonder if we should do a switch block or something along those lines... since there could be other language plugins added in the future 🤔

Maybe something like this? (To be clear... a pipe-dream of mine is to make a Astro Twoslasher 😅)

Suggested change
const isVue = codeBlock.language === 'vue';
const selectedTwoslasher = isVue ? twoslasherVue : twoslasher;
let selectedTwoslasher = twoslasher;
switch (codeBlock.language) {
case "vue": {
selectedTwoslasher = twoslasherVue;
break;
}
default: {
selectedTwoslasher = twoslasher;
break;
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair.

I'll add a comment on the changes I pushed :)

This is better prepared for future additions of supported languages.
Comment on lines +89 to +96
const availableTwoSlashers: Record<string, TwoslashInstance> = {
'default': createTwoslasher({
...twoslashOptions,
}),
'vue': createTwoslasherVue({
...twoslashOptions,
}),
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my mind, this will make it easy to extend the code in one place: you add a key and a TwoslashInstance and you're good to go.

// Select the appropriate twoslasher based on language
const isVue = codeBlock.language === 'vue';
const selectedTwoslasher = isVue ? twoslasherVue : twoslasher;
const selectedTwoslasher = availableTwoSlashers[codeBlock.language] ?? availableTwoSlashers.default;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then no need for a switch case here, since this line already picks up the matching language's TwoslashInstance.

@Adammatthiesen
Copy link
Member

Adammatthiesen commented Jan 26, 2026

I'll merge this soon, i'm also going to have to update the CI to allow OIDC NPM publishing... as i haven't done that for this repo yet... that way i'll be able to release the new version

@Adammatthiesen
Copy link
Member

Merging this now, but am prepping to move this repo to the withstudiocms org. So watch for releases from there!

@Adammatthiesen Adammatthiesen merged commit c2baab2 into withstudiocms:main Feb 12, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin Request: Add Vue support

2 participants

Comments