pi0 / nuxt-shiki

🎨 Nuxt + Shiki syntax highlighter
80 stars 2 forks source link

Support loading aliases #11

Closed atinux closed 9 months ago

atinux commented 9 months ago

Example:

export default defineNuxtConfig({
  shiki: {
    langs: ['bash']
  }
})
[nitro 7:47:12 PM]  ERROR  Error: Could not load /Users/atinux/my-project/node_modules/.pnpm/shiki@1.1.5/node_modules/shiki/dist/langs/bash.mjs

It would be nice to detect that it is an alias and load the corresponding language: powershell (See https://github.com/shikijs/shiki/blob/b9c0fb5fcc0c86d0e994ac0a51d990a9270a73f3/packages/shiki/src/assets/langs-bundle-full.ts#L834-L841)

Any hint on how to do this @antfu ?

antfu commented 9 months ago

Here is how I did in mdc module:

https://github.com/nuxt-modules/mdc/blob/cf7d72a17f2c1a1cc2dec42ab1042dccb2b2d504/src/templates/mdc-highlighter.ts#L33-L52

I don't mind creating stub modules for alias to be directly imported - but that might not work for every alias as not all aliases a valid ansi filenames - I will try

antfu commented 9 months ago

https://github.com/shikijs/shiki/pull/596 get merged - now this should just work if you upgrade shiki to 1.1.6

atinux commented 9 months ago

That was fast thank you @antfu !