Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfc9f43

Browse files
committed
fix(highlighter): support custom languages
closed #3067
1 parent 843e4b2 commit cfc9f43

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/content/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { hash } from 'ohash'
44
import type { Highlighter, MdcConfig, ModuleOptions as MDCModuleOptions } from '@nuxtjs/mdc'
55
import type { Nuxt } from '@nuxt/schema'
66
import { resolveAlias } from '@nuxt/kit'
7+
import type { LanguageRegistration } from 'shiki'
78
import { defu } from 'defu'
89
import { createOnigurumaEngine } from 'shiki/engine/oniguruma'
910
import { visit } from 'unist-util-visit'
@@ -52,8 +53,8 @@ async function _getHighlightPlugin(options: HighlighterOptions) {
5253
typeof theme === 'string' ? (await import(`shiki/themes/${theme}.mjs`).then(m => m.default || m)) : theme,
5354
]))
5455
const bundledLangs = await Promise.all(langs.map(async lang => [
55-
lang,
56-
await import(`@shikijs/langs/${lang}`).then(m => m.default || m),
56+
typeof lang === 'string' ? lang : (lang as unknown as LanguageRegistration).name,
57+
typeof lang === 'string' ? await import(`@shikijs/langs/${lang}`).then(m => m.default || m) : lang,
5758
]))
5859

5960
const highlighter = createShikiHighlighter({

0 commit comments

Comments
 (0)