Skip to content

Commit 0d7ee22

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 0d7ee22

24 files changed

+2000
-7541
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.js

Lines changed: 0 additions & 101 deletions
This file was deleted.

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 searchPlugin from '@vuepress/plugin-search'
3+
import { defaultTheme } from '@vuepress/theme-default'
4+
import smoothScrollPlugin from 'vuepress-plugin-smooth-scroll'
5+
6+
import includePlugin from './include-plugin'
7+
import { demoCodePlugin } from '../../src/node'
8+
import { name, description } from '../../package.json'
9+
10+
const ecosystemItems = [
11+
{ text: '📖markdown-it-vuese', link: 'https://buptsteve.github.io/markdown-it-vuese/' },
12+
]
13+
14+
export default defineUserConfig({
15+
base: `/${name}/`,
16+
locales: {
17+
'/': { lang: 'en-US', title: 'demo-code', description },
18+
'/zh/': {
19+
lang: 'zh-CN',
20+
title: 'demo-code',
21+
description: '📝 同时展示 demo 和 code 的 vuepress 插件',
22+
},
23+
},
24+
head: [
25+
['link', { rel: 'icon', href: '/favicon.ico' }],
26+
['link', { rel: 'stylesheet', href: 'https://unpkg.com/animate.css@3.7.0/animate.min.css' }],
27+
],
28+
plugins: [
29+
includePlugin,
30+
// @ts-ignore
31+
smoothScrollPlugin,
32+
demoCodePlugin({
33+
cssLibs: [
34+
'https://unpkg.com/animate.css@3.7.0/animate.min.css',
35+
],
36+
showText: 'show more',
37+
hideText: 'hide',
38+
}),
39+
searchPlugin({
40+
locales: {
41+
'/': {
42+
placeholder: 'Search',
43+
},
44+
'/zh/': {
45+
placeholder: '搜索',
46+
},
47+
},
48+
}),
49+
],
50+
theme: defaultTheme({
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+
}

docs/zh/example/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
```md
99
::: demo
1010
<template>
11-
<button class="animated shake infinite" @click="onClick">Click me!</button>
11+
<button class="animated shake infinite" @click="onClick">Click me!</button>
1212
</template>
1313

1414
<script>
1515
export default {
16-
methods: {
17-
onClick: () => { window.alert(1) },
18-
},
16+
methods: {
17+
onClick: () => { window.alert(1) },
18+
},
1919
}
2020
</script>
2121

2222
<style>
2323
button {
24-
color: blue;
24+
color: blue;
2525
}
2626
</style>
2727
:::
@@ -31,20 +31,20 @@ button {
3131

3232
::: demo
3333
<template>
34-
<button class="animated shake infinite" @click="onClick">Click me!</button>
34+
<button class="animated shake infinite" @click="onClick">Click me!</button>
3535
</template>
3636

3737
<script>
3838
export default {
39-
methods: {
40-
onClick: () => { window.alert(1) },
41-
},
39+
methods: {
40+
onClick: () => { window.alert(1) },
41+
},
4242
}
4343
</script>
4444

4545
<style>
4646
button {
47-
color: blue;
47+
color: blue;
4848
}
4949
</style>
5050
:::
@@ -57,12 +57,12 @@ button {
5757
```md
5858
::: demo html
5959
<p class="common-html">
60-
this is <span style="color: red;">common</span> html
60+
this is <span style="color: red;">common</span> html
6161
</p>
6262

6363
<style>
6464
.common-html {
65-
color: green;
65+
color: green;
6666
}
6767
</style>
6868
:::
@@ -72,12 +72,12 @@ button {
7272

7373
::: demo html
7474
<p class="common-html">
75-
this is <span style="color: red;">common</span> html
75+
this is <span style="color: red;">common</span> html
7676
</p>
7777

7878
<style>
7979
.common-html {
80-
color: green;
80+
color: green;
8181
}
8282
</style>
8383
:::

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
},

0 commit comments

Comments
 (0)