Skip to content

Commit

Permalink
feat(plugin-shiki): use shiki v1 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Feb 6, 2024
1 parent 93734f4 commit 2e4343c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/plugins/shiki.md
Expand Up @@ -41,7 +41,7 @@ export default {

This option will be forwarded to `getHighlighter()` method of shikiji.

You need to provide the languages list you are using explicitly, otherwise shikiji won't load any languages.
You'd better provide the languages list you are using explicitly, otherwise shikiji will load all languages and can affect performance.

- Also see:
- [shikiji > Languages](https://shikiji.netlify.app/languages)
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/plugins/shiki.md
Expand Up @@ -41,7 +41,7 @@ export default {

该配置项会被传递到 Shikiji 的 `getHighlighter()` 方法中。

你需要明确传入所有你使用的语言列表,否则 Shikiji 将不会加载任何语言
你最好明确传入所有你使用的语言列表,否则 Shikiji 会加载所有语言,并可能影响性能

- 参考:
- [shikiji > Languages](https://shikiji.netlify.app/languages)
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-shiki/package.json
Expand Up @@ -35,7 +35,7 @@
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
"shikiji": "^0.10.2"
"shiki": "^1.0.0-rc.0"
},
"peerDependencies": {
"vuepress": "2.0.0-rc.6"
Expand Down
8 changes: 5 additions & 3 deletions plugins/plugin-shiki/src/node/shikiPlugin.ts
@@ -1,4 +1,3 @@
import { getHighlighter } from 'shikiji'
import type {
BundledLanguage,
BundledTheme,
Expand All @@ -7,7 +6,8 @@ import type {
StringLiteralUnion,
ThemeRegistration,
ThemeRegistrationRaw,
} from 'shikiji'
} from 'shiki'
import { bundledLanguages, getHighlighter } from 'shiki/bundle/full'
import type { Plugin } from 'vuepress/core'

export type ShikiLang =
Expand Down Expand Up @@ -52,8 +52,10 @@ export interface ShikiPluginOptions {
}
}

const DEFAULT_LANGS = Object.keys(bundledLanguages)

export const shikiPlugin = ({
langs,
langs = DEFAULT_LANGS,
theme = 'nord',
themes,
}: ShikiPluginOptions = {}): Plugin => ({
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2e4343c

Please sign in to comment.