Skip to content

Commit 3c6d363

Browse files
committed
feat: support vuepress v2
BREAKING CHANGE: remove vuepress-plugin-code-copy "You cannot use other plugins in your plugin anymore, which avoids lots of potential issues caused by plugin nesting. If your plugin depends on other plugins, you should list them in the docs." fix #41
1 parent f950031 commit 3c6d363

20 files changed

+2003
-6909
lines changed

README-zh_CN.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ module.exports = {
110110
embed: '',
111111
},
112112
demoCodeMark: 'demo-code',
113-
copyOptions: { ... },
114113
}]
115114
],
116115
}
@@ -178,12 +177,6 @@ vue 的语义化版本字符串。想要了解更多的语义化版本格式,
178177

179178
插件的标记,即跟在 `:::` 后的标记。
180179

181-
### copyOptions
182-
* 类型:`Object/Boolean`
183-
* 默认值:`{ align: 'top', selector: '.demo-and-code-wrapper div[class*="language-"] pre' }`
184-
185-
透传 [vuepress-plugin-code-copy](https://github.com/znicholasbrown/vuepress-plugin-code-copy#options) 的参数,或传 `false` 禁用它。
186-
187180
## Related
188181
* [vuepress-plugin-demo-block](https://github.com/xiguaxigua/vuepress-plugin-demo-block)
189182

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ module.exports = {
110110
embed: '',
111111
},
112112
demoCodeMark: 'demo-code',
113-
copyOptions: { ... },
114113
}]
115114
],
116115
}
@@ -178,12 +177,6 @@ It passes [CodeSandbox options](https://codesandbox.io/docs/importing#define-api
178177

179178
The mark of the plugin, follows the tag after `:::`.
180179

181-
### copyOptions
182-
* Type: `Object/Boolean`
183-
* Default: `{ align: 'top', selector: '.demo-and-code-wrapper div[class*="language-"] pre' }`
184-
185-
It passes [vuepress-plugin-code-copy](https://github.com/znicholasbrown/vuepress-plugin-code-copy#options)'s options, or `false` to disable it.
186-
187180
## Related
188181
* [vuepress-plugin-demo-block](https://github.com/xiguaxigua/vuepress-plugin-demo-block)
189182

docs/.vuepress/config.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { defineUserConfig } from 'vuepress'
2+
import type { DefaultThemeOptions } from 'vuepress'
3+
4+
import demoCode from '../../src/node'
5+
import { name, description } from '../../package.json'
6+
7+
const ecosystemItems = [
8+
{ text: '📖markdown-it-vuese', link: 'https://buptsteve.github.io/markdown-it-vuese/' },
9+
]
10+
11+
export default defineUserConfig<DefaultThemeOptions>({
12+
base: `/${name}/`,
13+
locales: {
14+
'/': { lang: 'en-US', title: 'demo-code', description },
15+
'/zh/': {
16+
lang: 'zh-CN',
17+
title: 'demo-code',
18+
description: '📝 同时展示 demo 和 code 的 vuepress 插件',
19+
},
20+
},
21+
head: [
22+
['link', { rel: 'icon', href: '/favicon.ico' }],
23+
['link', { rel: 'stylesheet', href: 'https://unpkg.com/animate.css@3.7.0/animate.min.css' }],
24+
],
25+
plugins: [
26+
['smooth-scroll'],
27+
[demoCode, {
28+
cssLibs: [
29+
'https://unpkg.com/animate.css@3.7.0/animate.min.css',
30+
],
31+
vueVersion: '^3',
32+
showText: 'show more',
33+
hideText: 'hide',
34+
}],
35+
require('./include-plugin'),
36+
[
37+
'@vuepress/plugin-search',
38+
{
39+
locales: {
40+
'/': {
41+
placeholder: 'Search',
42+
},
43+
'/zh/': {
44+
placeholder: '搜索',
45+
},
46+
},
47+
},
48+
],
49+
],
50+
themeConfig: {
51+
repo: 'BuptStEve/' + name,
52+
docsDir: 'docs',
53+
contributors: false,
54+
locales: {
55+
'/': {
56+
selectLanguageText: '🌍Languages',
57+
selectLanguageName: 'English',
58+
editLinkText: 'Edit this page on GitHub',
59+
navbar: [
60+
{ text: '🌱Guide', link: '/' },
61+
{ text: '😎Example', link: '/example/' },
62+
{ text: '🔥Ecosystem', children: ecosystemItems },
63+
],
64+
sidebar: [
65+
{ text: '🌱Guide', link: '/' },
66+
{ text: '😎Example', link: '/example/' },
67+
],
68+
},
69+
'/zh/': {
70+
selectLanguageText: '🌍选择语言',
71+
selectLanguageName: '简体中文',
72+
editLinkText: '在 GitHub 上编辑此页',
73+
navbar: [
74+
{ text: '🌱指南', link: '/zh/' },
75+
{ text: '😎示例', link: '/zh/example/' },
76+
{ text: '🔥生态系统', children: ecosystemItems },
77+
],
78+
sidebar: [
79+
{ text: '🌱指南', link: '/zh/' },
80+
{ text: '😎示例', link: '/zh/example/' },
81+
],
82+
},
83+
},
84+
},
85+
})

docs/.vuepress/include-plugin.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
module.exports = () => {
3+
return {
4+
name: 'vuepress-plugin-include',
5+
extendsMarkdown: (md) => {
6+
md.use(require('markdown-it-include'), {
7+
root: './docs/',
8+
includeRe: /<\[include\](.+)/i,
9+
bracesAreOptional: true,
10+
})
11+
},
12+
}
13+
}

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ module.exports = {
55
collectCoverage: true,
66
collectCoverageFrom: [
77
'src/**',
8-
'!src/icons/**',
9-
'!src/highlight.js',
10-
'!src/enhanceAppFile.js',
8+
'!src/client/icons/**',
9+
'!src/client/highlight.js',
10+
'!src/client/enhanceAppFile.js',
1111
],
1212
coveragePathIgnorePatterns: ['/__snapshots__/'],
1313
transform: {
14-
'^.+\\.vue$': 'vue-jest',
14+
'^.+\\.vue$': '@vue/vue3-jest',
1515
'^.+\\.jsx?$': 'babel-jest',
1616
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
1717
},

package.json

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuepress-plugin-demo-code",
3-
"version": "1.0.0",
3+
"version": "2.0.0-beta.0",
44
"description": "📝 Demo and code plugin for vuepress",
55
"main": "src/node/index.js",
66
"types": "src/node/index.d.ts",
@@ -29,43 +29,49 @@
2929
}
3030
},
3131
"dependencies": {
32-
"codesandbox-import-utils": "^2.2.3",
33-
"markdown-it-container": "^3.0.0",
34-
"prismjs": "^1.28.0",
35-
"vuepress-plugin-code-copy": "^1.0.6"
32+
"@amoutonbrady/lz-string": "^0.0.1",
33+
"markdown-it-container": "^3.0.0"
3634
},
3735
"devDependencies": {
38-
"@babel/core": "^7.17.9",
39-
"@babel/eslint-parser": "^7.17.0",
40-
"@babel/preset-env": "^7.16.11",
41-
"@commitlint/cli": "^12.1.4",
42-
"@commitlint/config-conventional": "^12.1.4",
43-
"@vue/test-utils": "^1.3.0",
36+
"@babel/core": "^7.16.0",
37+
"@babel/eslint-parser": "^7.16.3",
38+
"@babel/preset-env": "^7.16.4",
39+
"@commitlint/cli": "^15.0.0",
40+
"@commitlint/config-conventional": "^15.0.0",
41+
"@types/escape-html": "^1.0.1",
42+
"@types/jest": "^27.4.1",
43+
"@vue/compiler-sfc": "^3.2.24",
44+
"@vue/test-utils": "^2.0.0-rc.17",
45+
"@vue/vue3-jest": "^27.0.0-alpha.4",
46+
"@vuepress/client": "2.0.0-beta.43",
47+
"@vuepress/plugin-search": "^2.0.0-beta.38",
4448
"all-contributors-cli": "^6.20.0",
4549
"babel-core": "^7.0.0-bridge.0",
46-
"bumpp": "^7.1.1",
47-
"codecov": "^3.8.3",
50+
"babel-jest": "^27.4.2",
51+
"codecov": "^3.8.2",
4852
"cross-env": "^7.0.3",
4953
"cz-conventional-changelog": "^3.3.0",
50-
"eslint": "^7.32.0",
54+
"eslint": "^8.4.1",
5155
"eslint-config-standard": "^16.0.3",
5256
"eslint-config-vue": "^2.0.2",
53-
"eslint-plugin-import": "^2.26.0",
57+
"eslint-plugin-import": "^2.25.3",
5458
"eslint-plugin-node": "^11.1.0",
5559
"eslint-plugin-promise": "^5.2.0",
56-
"eslint-plugin-standard": "^5.0.0",
57-
"eslint-plugin-vue": "^7.20.0",
60+
"eslint-plugin-vue": "^8.2.0",
5861
"gh-pages": "^3.2.3",
59-
"husky": "^6.0.0",
60-
"jest": "^27.5.1",
62+
"husky": "^7.0.4",
63+
"jest": "^27.4.3",
6164
"jest-serializer-vue": "^2.0.2",
6265
"jest-transform-stub": "^2.0.0",
63-
"lint-staged": "^11.2.6",
66+
"lint-staged": "^12.1.2",
67+
"markdown-it": "^13.0.0",
6468
"markdown-it-include": "^2.0.0",
6569
"rimraf": "^3.0.2",
6670
"standard-version": "^9.3.2",
67-
"vue-jest": "^3.0.7",
68-
"vuepress": "^1.9.7",
71+
"ts-jest": "^27.1.4",
72+
"typescript": "^4.6.4",
73+
"vue": "^3.2.33",
74+
"vuepress": "^2.0.0-beta.38",
6975
"vuepress-plugin-smooth-scroll": "^0.0.10"
7076
},
7177
"keywords": [

0 commit comments

Comments
 (0)