Skip to content

Commit fe0b917

Browse files
committed
fix: close #40, add DemoCodePluginOptions
1 parent 9866b99 commit fe0b917

File tree

3 files changed

+77
-35
lines changed

3 files changed

+77
-35
lines changed

docs/.vuepress/config.js

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
const demoCode = require('../../src/')
1+
const { defineConfig } = require('vuepress/config')
2+
3+
const demoCode = require('../../src')
24
const { name, description } = require('../../package.json')
35

4-
const ecosystemItems = [
5-
{ text: '📖markdown-it-vuese', link: 'https://buptsteve.github.io/markdown-it-vuese/' },
6-
]
6+
/**
7+
* @type {import('../../src/').DemoCodePluginOptions}
8+
*/
9+
const demoCodeOptions = {
10+
cssLibs: [
11+
'https://unpkg.com/animate.css@3.7.0/animate.min.css',
12+
],
13+
showText: 'show more',
14+
hideText: 'hide',
15+
}
716

8-
module.exports = {
9-
base: '/' + name + '/',
17+
module.exports = defineConfig({
18+
base: `/${name}/`,
1019
locales: {
1120
'/': { lang: 'en-US', title: 'demo-code', description },
1221
'/zh/': {
@@ -21,13 +30,8 @@ module.exports = {
2130
],
2231
plugins: [
2332
['smooth-scroll'],
24-
[demoCode, {
25-
cssLibs: [
26-
'https://unpkg.com/animate.css@3.7.0/animate.min.css',
27-
],
28-
showText: 'show more',
29-
hideText: 'hide',
30-
}],
33+
// @ts-ignore
34+
[demoCode, demoCodeOptions],
3135
],
3236
markdown: {
3337
extendMarkdown: (md) => {
@@ -45,27 +49,20 @@ module.exports = {
4549
docsDir: 'docs',
4650
sidebarDepth: 2,
4751
editLinks: true,
48-
serviceWorker: {
49-
updatePopup: {
50-
message: 'New content is available.',
51-
buttonText: 'Refresh',
52-
},
53-
},
5452
locales: {
5553
'/': {
5654
selectText: '🌍Languages',
5755
label: 'English',
5856
editLinkText: 'Edit this page on GitHub',
59-
serviceWorker: {
60-
updatePopup: {
61-
message: 'New content is available.',
62-
buttonText: 'Refresh',
63-
},
64-
},
6557
nav: [
6658
{ text: '🌱Guide', link: '/' },
6759
{ text: '😎Example', link: '/example/' },
68-
{ text: '🔥Ecosystem', items: ecosystemItems },
60+
{
61+
text: '🔥Ecosystem',
62+
items: [
63+
{ text: '📖markdown-it-vuese', link: 'https://buptsteve.github.io/markdown-it-vuese/' },
64+
],
65+
},
6966
],
7067
sidebar: {
7168
'/example/': [{
@@ -80,16 +77,15 @@ module.exports = {
8077
selectText: '🌍选择语言',
8178
label: '简体中文',
8279
editLinkText: '在 GitHub 上编辑此页',
83-
serviceWorker: {
84-
updatePopup: {
85-
message: '文档有更新。',
86-
buttonText: '刷新',
87-
},
88-
},
8980
nav: [
9081
{ text: '🌱指南', link: '/zh/' },
9182
{ text: '😎示例', link: '/zh/example/' },
92-
{ text: '🔥生态系统', items: ecosystemItems },
83+
{
84+
text: '🔥生态系统',
85+
items: [
86+
{ text: '📖markdown-it-vuese', link: 'https://buptsteve.github.io/markdown-it-vuese/' },
87+
],
88+
},
9389
],
9490
sidebar: {
9591
'/zh/example/': [{
@@ -102,4 +98,4 @@ module.exports = {
10298
},
10399
},
104100
},
105-
}
101+
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "vuepress-plugin-demo-code",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "📝 Demo and code plugin for vuepress",
55
"main": "src/index.js",
6+
"types": "src/index.d.ts",
67
"files": [
78
"src"
89
],

src/index.d.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
export interface DemoCodePluginOptions {
2+
/** Js libraries for the demo. */
3+
jsLibs?: string[],
4+
/** Css libraries for the demo. */
5+
cssLibs?: string[],
6+
/**
7+
* The semantic version string of vue. For more information on semantic versioning syntax, see the [npm semver calculator](https://semver.npmjs.com/).
8+
*/
9+
vueVersion?: string,
10+
/** The display text of unfold code button. */
11+
showText?: string,
12+
/** The display text of fold code button. */
13+
hideText?: string,
14+
/** The height of the code when it is folded. */
15+
minHeight?: number,
16+
/** Display online edit buttons. */
17+
onlineBtns?: {
18+
codepen?: boolean,
19+
jsfiddle?: boolean,
20+
codesandbox?: boolean,
21+
},
22+
/**
23+
* It passes [jsfiddle options](https://docs.jsfiddle.net/api/display-a-fiddle-from-post).
24+
*/
25+
jsfiddle?: Record<string, string>,
26+
/**
27+
* It passes [CodeSandbox options](https://codesandbox.io/docs/importing#define-api).
28+
* > `deps` is dependencies
29+
*/
30+
codesandbox?: {
31+
deps?: Record<string, string>
32+
json?: string,
33+
query?: string,
34+
embed?: string,
35+
},
36+
/** The mark of the plugin, follows the tag after `:::`. */
37+
demoCodeMark?: string,
38+
/**
39+
* It passes [vuepress-plugin-code-copy](https://github.com/znicholasbrown/vuepress-plugin-code-copy#options)'s options, or `false` to disable it.
40+
*/
41+
copyOptions?: false | {
42+
align?: string,
43+
selector?: string,
44+
},
45+
}

0 commit comments

Comments
 (0)