@vuepress/plugin-shiki 2.0.0-rc.0 → 2.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018-present, Yuxi (Evan) You
3
+ Copyright (c) 2018-present, VuePress Community
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,34 @@
1
- import type { Plugin } from '@vuepress/core';
2
- import type { HighlighterOptions } from 'shiki';
1
+ import type { BundledLanguage, BundledTheme, LanguageInput, SpecialLanguage, StringLiteralUnion, ThemeRegistration, ThemeRegistrationRaw } from 'shikiji';
2
+ import type { Plugin } from 'vuepress/core';
3
+ export type ShikiLang = LanguageInput | StringLiteralUnion<BundledLanguage> | SpecialLanguage;
4
+ export type ShikiTheme = ThemeRegistration | ThemeRegistrationRaw | StringLiteralUnion<BundledTheme>;
3
5
  /**
4
6
  * Options of @vuepress/plugin-shiki
5
7
  */
6
- export type ShikiPluginOptions = Pick<HighlighterOptions, 'theme' | 'langs'>;
7
- export declare const shikiPlugin: ({ theme, langs, }?: ShikiPluginOptions) => Plugin;
8
+ export interface ShikiPluginOptions {
9
+ /**
10
+ * Languages to be loaded.
11
+ *
12
+ * Shikiji does not preload any languages to avoid extra overhead. So you need
13
+ * to specify the languages you want to use.
14
+ *
15
+ * @see https://shikiji.netlify.app/languages
16
+ */
17
+ langs?: ShikiLang[];
18
+ /**
19
+ * The single theme to use
20
+ *
21
+ * @see https://shikiji.netlify.app/themes
22
+ */
23
+ theme?: ShikiTheme;
24
+ /**
25
+ * The dark and light themes to use
26
+ *
27
+ * @see https://shikiji.netlify.app/themes
28
+ */
29
+ themes?: {
30
+ dark: ShikiTheme;
31
+ light: ShikiTheme;
32
+ };
33
+ }
34
+ export declare const shikiPlugin: ({ langs, theme, themes, }?: ShikiPluginOptions) => Plugin;
@@ -1,13 +1,14 @@
1
- import { getHighlighter } from 'shiki';
2
- export const shikiPlugin = ({ theme = 'nord', langs, } = {}) => ({
1
+ import { getHighlighter } from 'shikiji';
2
+ export const shikiPlugin = ({ langs, theme = 'nord', themes, } = {}) => ({
3
3
  name: '@vuepress/plugin-shiki',
4
4
  extendsMarkdown: async (md) => {
5
5
  const highlighter = await getHighlighter({
6
- theme,
7
6
  langs,
7
+ themes: themes ? [themes.dark, themes.light] : [theme],
8
8
  });
9
9
  md.options.highlight = (code, lang) => highlighter.codeToHtml(code, {
10
10
  lang,
11
+ ...(themes ? { themes } : { theme }),
11
12
  });
12
13
  },
13
14
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/plugin-shiki",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0-rc.3",
4
4
  "description": "VuePress plugin - shiki",
5
5
  "keywords": [
6
6
  "vuepress-plugin",
@@ -11,11 +11,12 @@
11
11
  ],
12
12
  "homepage": "https://github.com/vuepress",
13
13
  "bugs": {
14
- "url": "https://github.com/vuepress/vuepress-next/issues"
14
+ "url": "https://github.com/vuepress/ecosystem/issues"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "git+https://github.com/vuepress/vuepress-next.git"
18
+ "url": "git+https://github.com/vuepress/ecosystem.git",
19
+ "directory": "plugins/plugin-shiki"
19
20
  },
20
21
  "license": "MIT",
21
22
  "author": "meteorlxy",
@@ -29,15 +30,18 @@
29
30
  "files": [
30
31
  "lib"
31
32
  ],
33
+ "scripts": {
34
+ "build": "tsc -b tsconfig.build.json",
35
+ "clean": "rimraf --glob ./lib ./*.tsbuildinfo"
36
+ },
32
37
  "dependencies": {
33
- "shiki": "^0.14.5",
34
- "@vuepress/core": "2.0.0-rc.0"
38
+ "shikiji": "^0.10.2"
39
+ },
40
+ "peerDependencies": {
41
+ "vuepress": "2.0.0-rc.2"
35
42
  },
36
43
  "publishConfig": {
37
44
  "access": "public"
38
45
  },
39
- "scripts": {
40
- "build": "tsc -b tsconfig.build.json",
41
- "clean": "rimraf lib *.tsbuildinfo"
42
- }
43
- }
46
+ "gitHead": "7247c765f50c3b2d5a622e0f7cf22bfb13a463c4"
47
+ }