Skip to content

Commit a1909c0

Browse files
committedJun 22, 2022
refactor(markdown): externalize custom component plugin
BREAKING CHANGE: `markdown.customComponent` has been renamed to `markdown.component`
1 parent 943260f commit a1909c0

File tree

16 files changed

+23
-1129
lines changed

16 files changed

+23
-1129
lines changed
 

‎.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"frontmatter",
2727
"globby",
2828
"gtag",
29+
"mdit",
2930
"nprogress",
3031
"prefetch",
3132
"preload",

‎docs/reference/config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,13 @@ You can disable it if you want to implement them in client side. For example, [P
461461
- Also see:
462462
- [Guide > Markdown > Syntax Extensions > Code Blocks > Wrap with v-pre](../guide/markdown.md#wrap-with-v-pre)
463463

464-
### markdown.customComponent
464+
### markdown.component
465465

466466
- Type: `undefined | false`
467467

468468
- Details:
469469

470-
Options for VuePress built-in markdown-it custom-component plugin.
470+
Options for [@mdit-vue/plugin-component](https://www.npmjs.com/package/@mdit-vue/plugin-component).
471471

472472
Set to `false` to disable this plugin.
473473

‎docs/zh/reference/config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,13 @@ VuePress 在开发和构建时会加载临时文件,因此临时文件目录
460460
- 参考:
461461
- [指南 > Markdown > 语法扩展 > 代码块 > 添加 v-pre](../guide/markdown.md#添加-v-pre)
462462

463-
### markdown.customComponent
463+
### markdown.component
464464

465465
- 类型: `undefined | false`
466466

467467
- 详情:
468468

469-
VuePress 内置的 markdown-it custom-component 插件的配置项。
469+
[@mdit-vue/plugin-component](https://www.npmjs.com/package/@mdit-vue/plugin-component) 插件的配置项。
470470

471471
设置为 `false` 可以禁用该插件。
472472

‎packages/@vuepress/markdown/__tests__/plugins/customComponentPlugin.spec.ts

-804
This file was deleted.

‎packages/@vuepress/markdown/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"clean": "rimraf lib *.tsbuildinfo"
2727
},
2828
"dependencies": {
29+
"@mdit-vue/plugin-component": "^0.1.0",
2930
"@types/markdown-it": "^12.2.3",
3031
"@vuepress/shared": "workspace:*",
3132
"@vuepress/utils": "workspace:*",

‎packages/@vuepress/markdown/src/markdown.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
anchorPlugin,
44
assetsPlugin,
55
codePlugin,
6-
customComponentPlugin,
6+
componentPlugin,
77
emojiPlugin,
88
extractHeadersPlugin,
99
extractTitlePlugin,
@@ -33,7 +33,7 @@ export const createMarkdown = ({
3333
anchor,
3434
assets,
3535
code,
36-
customComponent,
36+
component,
3737
emoji,
3838
extractHeaders,
3939
extractTitle,
@@ -103,9 +103,9 @@ export const createMarkdown = ({
103103
// following plugins modify or replace the rule in place
104104
// and have no conflicts, so the order is not important
105105

106-
// treat unknown html tags as custom components
107-
if (customComponent !== false) {
108-
md.use(customComponentPlugin)
106+
// treat unknown html tags as components
107+
if (component !== false) {
108+
md.use(componentPlugin)
109109
}
110110

111111
// replace relative link of assets with absolute link

‎packages/@vuepress/markdown/src/plugins/customComponentPlugin/customComponentPlugin.ts

-16
This file was deleted.

‎packages/@vuepress/markdown/src/plugins/customComponentPlugin/htmlBlockRule.ts

-111
This file was deleted.

‎packages/@vuepress/markdown/src/plugins/customComponentPlugin/htmlInlineRule.ts

-47
This file was deleted.

‎packages/@vuepress/markdown/src/plugins/customComponentPlugin/htmlRe.ts

-45
This file was deleted.

‎packages/@vuepress/markdown/src/plugins/customComponentPlugin/index.ts

-6
This file was deleted.

‎packages/@vuepress/markdown/src/plugins/customComponentPlugin/inlineTags.ts

-75
This file was deleted.

‎packages/@vuepress/markdown/src/plugins/customComponentPlugin/vueReservedTags.ts

-14
This file was deleted.

‎packages/@vuepress/markdown/src/plugins/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
export * from '@mdit-vue/plugin-component'
2+
13
export * from './anchorPlugin'
24
export * from './assetsPlugin'
35
export * from './codePlugin'
4-
export * from './customComponentPlugin'
56
export * from './emojiPlugin'
67
export * from './extractHeadersPlugin'
78
export * from './extractTitlePlugin'

‎packages/@vuepress/markdown/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface MarkdownOptions extends MarkdownIt.Options {
1818
anchor?: false | AnchorPluginOptions
1919
assets?: false | AssetsPluginOptions
2020
code?: false | CodePluginOptions
21-
customComponent?: false
21+
component?: false
2222
emoji?: false | EmojiPluginOptions
2323
extractHeaders?: false | ExtractHeadersPluginOptions
2424
extractTitle?: false

‎pnpm-lock.yaml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.