vitepress-plugin-field 0.3.0 → 0.4.0
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/dist/client/browser/index.d.ts +48 -5
- package/dist/client/browser/index.js +48 -0
- package/dist/client/ssr/index.d.ts +48 -5
- package/dist/client/ssr/index.js +48 -0
- package/dist/node/index.d.ts +48 -0
- package/dist/node/index.js +68 -6
- package/package.json +7 -3
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import { EnhanceAppContext } from "vitepress";
|
|
2
2
|
|
|
3
3
|
//#region src/client/VPField.vue.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vue component that renders a single field documentation entry.
|
|
6
|
+
*
|
|
7
|
+
* Renders the field name, optional badges (Required/Optional/Deprecated),
|
|
8
|
+
* type annotation, default value, and a description slot. Used by the
|
|
9
|
+
* `::: field` markdown container to display structured field information.
|
|
10
|
+
*
|
|
11
|
+
* Vue 组件,渲染单个字段文档条目。
|
|
12
|
+
*
|
|
13
|
+
* 渲染字段名称、可选徽章(Required/Optional/Deprecated)、类型注解、默认值
|
|
14
|
+
* 以及描述插槽。由 `::: field` markdown 容器用于展示结构化的字段信息。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```vue
|
|
18
|
+
* <VPField name="username" type="string" required>
|
|
19
|
+
* The username used to log in.
|
|
20
|
+
* </VPField>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
4
23
|
type __VLS_Props = {
|
|
5
|
-
name: string;
|
|
6
|
-
type?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
optional?: boolean;
|
|
9
|
-
deprecated?: boolean;
|
|
24
|
+
/** Field name displayed as the title / 显示为标题的字段名称 */name: string; /** Type annotation rendered as inline code / 以行内代码渲染的类型注解 */
|
|
25
|
+
type?: string; /** Whether the field is required (shows "Required" badge) / 字段是否为必填(显示 "Required" 徽章) */
|
|
26
|
+
required?: boolean; /** Whether the field is optional (shows "Optional" badge) / 字段是否为可选(显示 "Optional" 徽章) */
|
|
27
|
+
optional?: boolean; /** Whether the field is deprecated (shows "Deprecated" badge) / 字段是否已弃用(显示 "Deprecated" 徽章) */
|
|
28
|
+
deprecated?: boolean; /** Default value rendered as inline code / 以行内代码渲染的默认值 */
|
|
10
29
|
defaultValue?: string;
|
|
11
30
|
};
|
|
12
31
|
declare var __VLS_1: {};
|
|
@@ -23,6 +42,30 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
23
42
|
};
|
|
24
43
|
//#endregion
|
|
25
44
|
//#region src/client/index.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Client-side setup for `vitepress-plugin-field`.
|
|
47
|
+
*
|
|
48
|
+
* Registers the `<VPField>` component globally so it can be used in
|
|
49
|
+
* markdown-rendered content without explicit imports.
|
|
50
|
+
*
|
|
51
|
+
* `vitepress-plugin-field` 的客户端设置。
|
|
52
|
+
*
|
|
53
|
+
* 全局注册 `<VPField>` 组件,使其在 markdown 渲染的内容中无需显式导入即可使用。
|
|
54
|
+
*
|
|
55
|
+
* @param param0 - The VitePress enhance app context / VitePress 增强应用上下文
|
|
56
|
+
* @param param0.app - The Vue app instance to register the component on / 要注册组件的 Vue 应用实例
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // In `.vitepress/theme/index.ts`
|
|
60
|
+
* import { enhanceAppWithField } from 'vitepress-plugin-field/client'
|
|
61
|
+
*
|
|
62
|
+
* export default {
|
|
63
|
+
* enhanceApp(ctx) {
|
|
64
|
+
* enhanceAppWithField(ctx)
|
|
65
|
+
* },
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
26
69
|
declare function enhanceAppWithField({
|
|
27
70
|
app
|
|
28
71
|
}: EnhanceAppContext): void;
|
|
@@ -19,6 +19,25 @@ const _hoisted_6 = {
|
|
|
19
19
|
key: 1,
|
|
20
20
|
class: "description"
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Vue component that renders a single field documentation entry.
|
|
24
|
+
*
|
|
25
|
+
* Renders the field name, optional badges (Required/Optional/Deprecated),
|
|
26
|
+
* type annotation, default value, and a description slot. Used by the
|
|
27
|
+
* `::: field` markdown container to display structured field information.
|
|
28
|
+
*
|
|
29
|
+
* Vue 组件,渲染单个字段文档条目。
|
|
30
|
+
*
|
|
31
|
+
* 渲染字段名称、可选徽章(Required/Optional/Deprecated)、类型注解、默认值
|
|
32
|
+
* 以及描述插槽。由 `::: field` markdown 容器用于展示结构化的字段信息。
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```vue
|
|
36
|
+
* <VPField name="username" type="string" required>
|
|
37
|
+
* The username used to log in.
|
|
38
|
+
* </VPField>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
22
41
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
23
42
|
__name: "VPField",
|
|
24
43
|
props: {
|
|
@@ -30,6 +49,11 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
30
49
|
defaultValue: {}
|
|
31
50
|
},
|
|
32
51
|
setup(__props) {
|
|
52
|
+
/**
|
|
53
|
+
* Resolves the badge label based on the required/optional flags.
|
|
54
|
+
*
|
|
55
|
+
* 根据 required/optional 标志解析徽章标签。
|
|
56
|
+
*/
|
|
33
57
|
const badge = computed(() => __props.required ? "Required" : __props.optional ? "Optional" : "");
|
|
34
58
|
return (_ctx, _cache) => {
|
|
35
59
|
return openBlock(), createElementBlock("div", { class: normalizeClass(["vp-field", {
|
|
@@ -57,6 +81,30 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
57
81
|
});
|
|
58
82
|
//#endregion
|
|
59
83
|
//#region src/client/index.ts
|
|
84
|
+
/**
|
|
85
|
+
* Client-side setup for `vitepress-plugin-field`.
|
|
86
|
+
*
|
|
87
|
+
* Registers the `<VPField>` component globally so it can be used in
|
|
88
|
+
* markdown-rendered content without explicit imports.
|
|
89
|
+
*
|
|
90
|
+
* `vitepress-plugin-field` 的客户端设置。
|
|
91
|
+
*
|
|
92
|
+
* 全局注册 `<VPField>` 组件,使其在 markdown 渲染的内容中无需显式导入即可使用。
|
|
93
|
+
*
|
|
94
|
+
* @param param0 - The VitePress enhance app context / VitePress 增强应用上下文
|
|
95
|
+
* @param param0.app - The Vue app instance to register the component on / 要注册组件的 Vue 应用实例
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* // In `.vitepress/theme/index.ts`
|
|
99
|
+
* import { enhanceAppWithField } from 'vitepress-plugin-field/client'
|
|
100
|
+
*
|
|
101
|
+
* export default {
|
|
102
|
+
* enhanceApp(ctx) {
|
|
103
|
+
* enhanceAppWithField(ctx)
|
|
104
|
+
* },
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
60
108
|
function enhanceAppWithField({ app }) {
|
|
61
109
|
app.component("VPField", _sfc_main);
|
|
62
110
|
}
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import { EnhanceAppContext } from "vitepress";
|
|
2
2
|
|
|
3
3
|
//#region src/client/VPField.vue.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vue component that renders a single field documentation entry.
|
|
6
|
+
*
|
|
7
|
+
* Renders the field name, optional badges (Required/Optional/Deprecated),
|
|
8
|
+
* type annotation, default value, and a description slot. Used by the
|
|
9
|
+
* `::: field` markdown container to display structured field information.
|
|
10
|
+
*
|
|
11
|
+
* Vue 组件,渲染单个字段文档条目。
|
|
12
|
+
*
|
|
13
|
+
* 渲染字段名称、可选徽章(Required/Optional/Deprecated)、类型注解、默认值
|
|
14
|
+
* 以及描述插槽。由 `::: field` markdown 容器用于展示结构化的字段信息。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```vue
|
|
18
|
+
* <VPField name="username" type="string" required>
|
|
19
|
+
* The username used to log in.
|
|
20
|
+
* </VPField>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
4
23
|
type __VLS_Props = {
|
|
5
|
-
name: string;
|
|
6
|
-
type?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
optional?: boolean;
|
|
9
|
-
deprecated?: boolean;
|
|
24
|
+
/** Field name displayed as the title / 显示为标题的字段名称 */name: string; /** Type annotation rendered as inline code / 以行内代码渲染的类型注解 */
|
|
25
|
+
type?: string; /** Whether the field is required (shows "Required" badge) / 字段是否为必填(显示 "Required" 徽章) */
|
|
26
|
+
required?: boolean; /** Whether the field is optional (shows "Optional" badge) / 字段是否为可选(显示 "Optional" 徽章) */
|
|
27
|
+
optional?: boolean; /** Whether the field is deprecated (shows "Deprecated" badge) / 字段是否已弃用(显示 "Deprecated" 徽章) */
|
|
28
|
+
deprecated?: boolean; /** Default value rendered as inline code / 以行内代码渲染的默认值 */
|
|
10
29
|
defaultValue?: string;
|
|
11
30
|
};
|
|
12
31
|
declare var __VLS_1: {};
|
|
@@ -23,6 +42,30 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
23
42
|
};
|
|
24
43
|
//#endregion
|
|
25
44
|
//#region src/client/index.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Client-side setup for `vitepress-plugin-field`.
|
|
47
|
+
*
|
|
48
|
+
* Registers the `<VPField>` component globally so it can be used in
|
|
49
|
+
* markdown-rendered content without explicit imports.
|
|
50
|
+
*
|
|
51
|
+
* `vitepress-plugin-field` 的客户端设置。
|
|
52
|
+
*
|
|
53
|
+
* 全局注册 `<VPField>` 组件,使其在 markdown 渲染的内容中无需显式导入即可使用。
|
|
54
|
+
*
|
|
55
|
+
* @param param0 - The VitePress enhance app context / VitePress 增强应用上下文
|
|
56
|
+
* @param param0.app - The Vue app instance to register the component on / 要注册组件的 Vue 应用实例
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // In `.vitepress/theme/index.ts`
|
|
60
|
+
* import { enhanceAppWithField } from 'vitepress-plugin-field/client'
|
|
61
|
+
*
|
|
62
|
+
* export default {
|
|
63
|
+
* enhanceApp(ctx) {
|
|
64
|
+
* enhanceAppWithField(ctx)
|
|
65
|
+
* },
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
26
69
|
declare function enhanceAppWithField({
|
|
27
70
|
app
|
|
28
71
|
}: EnhanceAppContext): void;
|
package/dist/client/ssr/index.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { computed, defineComponent, mergeProps, useSSRContext } from "vue";
|
|
2
2
|
import { ssrInterpolate, ssrRenderAttrs, ssrRenderClass, ssrRenderSlot } from "vue/server-renderer";
|
|
3
3
|
//#region src/client/VPField.vue
|
|
4
|
+
/**
|
|
5
|
+
* Vue component that renders a single field documentation entry.
|
|
6
|
+
*
|
|
7
|
+
* Renders the field name, optional badges (Required/Optional/Deprecated),
|
|
8
|
+
* type annotation, default value, and a description slot. Used by the
|
|
9
|
+
* `::: field` markdown container to display structured field information.
|
|
10
|
+
*
|
|
11
|
+
* Vue 组件,渲染单个字段文档条目。
|
|
12
|
+
*
|
|
13
|
+
* 渲染字段名称、可选徽章(Required/Optional/Deprecated)、类型注解、默认值
|
|
14
|
+
* 以及描述插槽。由 `::: field` markdown 容器用于展示结构化的字段信息。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```vue
|
|
18
|
+
* <VPField name="username" type="string" required>
|
|
19
|
+
* The username used to log in.
|
|
20
|
+
* </VPField>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
4
23
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
5
24
|
__name: "VPField",
|
|
6
25
|
__ssrInlineRender: true,
|
|
@@ -13,6 +32,11 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
13
32
|
defaultValue: {}
|
|
14
33
|
},
|
|
15
34
|
setup(__props) {
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the badge label based on the required/optional flags.
|
|
37
|
+
*
|
|
38
|
+
* 根据 required/optional 标志解析徽章标签。
|
|
39
|
+
*/
|
|
16
40
|
const badge = computed(() => __props.required ? "Required" : __props.optional ? "Optional" : "");
|
|
17
41
|
return (_ctx, _push, _parent, _attrs) => {
|
|
18
42
|
_push(`<div${ssrRenderAttrs(mergeProps({ class: ["vp-field", {
|
|
@@ -49,6 +73,30 @@ _sfc_main.setup = (props, ctx) => {
|
|
|
49
73
|
};
|
|
50
74
|
//#endregion
|
|
51
75
|
//#region src/client/index.ts
|
|
76
|
+
/**
|
|
77
|
+
* Client-side setup for `vitepress-plugin-field`.
|
|
78
|
+
*
|
|
79
|
+
* Registers the `<VPField>` component globally so it can be used in
|
|
80
|
+
* markdown-rendered content without explicit imports.
|
|
81
|
+
*
|
|
82
|
+
* `vitepress-plugin-field` 的客户端设置。
|
|
83
|
+
*
|
|
84
|
+
* 全局注册 `<VPField>` 组件,使其在 markdown 渲染的内容中无需显式导入即可使用。
|
|
85
|
+
*
|
|
86
|
+
* @param param0 - The VitePress enhance app context / VitePress 增强应用上下文
|
|
87
|
+
* @param param0.app - The Vue app instance to register the component on / 要注册组件的 Vue 应用实例
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* // In `.vitepress/theme/index.ts`
|
|
91
|
+
* import { enhanceAppWithField } from 'vitepress-plugin-field/client'
|
|
92
|
+
*
|
|
93
|
+
* export default {
|
|
94
|
+
* enhanceApp(ctx) {
|
|
95
|
+
* enhanceAppWithField(ctx)
|
|
96
|
+
* },
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
52
100
|
function enhanceAppWithField({ app }) {
|
|
53
101
|
app.component("VPField", _sfc_main);
|
|
54
102
|
}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,9 +1,57 @@
|
|
|
1
1
|
import { PluginSimple } from "markdown-it";
|
|
2
2
|
|
|
3
3
|
//#region src/node/plugin.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* VitePress plugin for rendering structured field documentation blocks.
|
|
6
|
+
*
|
|
7
|
+
* Registers a markdown-it container plugin that transforms `::: field` blocks
|
|
8
|
+
* into interactive `<VPField>` Vue components, and wires up the client-side
|
|
9
|
+
* component registration via `enhanceAppWithField`.
|
|
10
|
+
*
|
|
11
|
+
* VitePress 插件,用于渲染结构化的字段文档块。
|
|
12
|
+
*
|
|
13
|
+
* 注册 markdown-it 容器插件,将 `::: field` 块转换为交互式 `<VPField>` Vue 组件,
|
|
14
|
+
* 并通过 `enhanceAppWithField` 完成客户端组件注册。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* `.vitepress/config.ts`
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { defineConfig } from 'vitepress-tuck'
|
|
20
|
+
* import field from 'vitepress-plugin-field'
|
|
21
|
+
*
|
|
22
|
+
* export default defineConfig({
|
|
23
|
+
* plugins: [field()],
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
4
27
|
declare const field: (options?: unknown) => import("vitepress-tuck").VitepressPlugin;
|
|
5
28
|
//#endregion
|
|
6
29
|
//#region src/node/markdown.d.ts
|
|
30
|
+
/**
|
|
31
|
+
* markdown-it plugin that registers `::: field` and `::: field-group` containers.
|
|
32
|
+
*
|
|
33
|
+
* Registers two container syntaxes:
|
|
34
|
+
* - `::: field-group` — wraps a group of fields in a `<div class="vp-field-group">`
|
|
35
|
+
* - `::: field` — parses the container body via `parseFieldContent` and renders
|
|
36
|
+
* a `<VPField>` Vue component with the extracted props
|
|
37
|
+
*
|
|
38
|
+
* markdown-it 插件,注册 `::: field` 和 `::: field-group` 容器。
|
|
39
|
+
*
|
|
40
|
+
* 注册两种容器语法:
|
|
41
|
+
* - `::: field-group` — 将一组字段包裹在 `<div class="vp-field-group">` 中
|
|
42
|
+
* - `::: field` — 通过 `parseFieldContent` 解析容器正文,并渲染带有提取属性的
|
|
43
|
+
* `<VPField>` Vue 组件
|
|
44
|
+
*
|
|
45
|
+
* @param md - The markdown-it instance to extend / 要扩展的 markdown-it 实例
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import MarkdownIt from 'markdown-it'
|
|
49
|
+
* import { fieldMarkdownPlugin } from 'vitepress-plugin-field/node'
|
|
50
|
+
*
|
|
51
|
+
* const md = new MarkdownIt()
|
|
52
|
+
* md.use(fieldMarkdownPlugin)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
7
55
|
declare const fieldMarkdownPlugin: PluginSimple;
|
|
8
56
|
//#endregion
|
|
9
57
|
export { field as default, field, fieldMarkdownPlugin };
|
package/dist/node/index.js
CHANGED
|
@@ -2,8 +2,12 @@ import { definePlugin } from "vitepress-tuck";
|
|
|
2
2
|
import { isUndefined } from "@pengzhanbo/utils";
|
|
3
3
|
import { createContainerPlugin, createContainerSyntaxPlugin, stringifyAttrs } from "vitepress-plugin-toolkit";
|
|
4
4
|
//#region src/node/parseFieldContent.ts
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Tags that carry structured meaning; everything else is description text.
|
|
7
|
+
*
|
|
8
|
+
* 携带结构化含义的标签;其他内容均视为描述文本。
|
|
9
|
+
*/
|
|
10
|
+
const KNOWN_TAGS = /* @__PURE__ */ new Set([
|
|
7
11
|
"name",
|
|
8
12
|
"type",
|
|
9
13
|
"default",
|
|
@@ -41,8 +45,8 @@ const KNOWN_TAGS = new Set([
|
|
|
41
45
|
* 未知的以 `@` 开头的标签将被视为描述文本。
|
|
42
46
|
* 空行会被忽略,且不会中断描述段落。
|
|
43
47
|
*
|
|
44
|
-
* @param content Raw text inside the `:::` container
|
|
45
|
-
* @param info
|
|
48
|
+
* @param content - Raw text inside the `:::` container / `:::` 容器内的原始文本
|
|
49
|
+
* @param info - Text after `::: field` on the opening line (the field name) / 起始行中 `::: field` 之后的文本(字段名称)
|
|
46
50
|
*/
|
|
47
51
|
function parseFieldContent(content, info) {
|
|
48
52
|
const lines = content.split("\n");
|
|
@@ -50,10 +54,15 @@ function parseFieldContent(content, info) {
|
|
|
50
54
|
name: info.trim(),
|
|
51
55
|
description: ""
|
|
52
56
|
};
|
|
53
|
-
/** Accumulates the current description paragraph. */
|
|
57
|
+
/** Accumulates the current description paragraph. / 累积当前描述段落。 */
|
|
54
58
|
let currentDesc = "";
|
|
55
|
-
/** Completed description segments, joined with `\n` at the end. */
|
|
59
|
+
/** Completed description segments, joined with `\n` at the end. / 已完成的描述片段,最后以 `\n` 连接。 */
|
|
56
60
|
const descriptions = [];
|
|
61
|
+
/**
|
|
62
|
+
* Flushes the accumulated description paragraph into the `descriptions` array.
|
|
63
|
+
*
|
|
64
|
+
* 将已累积的描述段落刷新到 `descriptions` 数组中。
|
|
65
|
+
*/
|
|
57
66
|
function flushDesc() {
|
|
58
67
|
if (currentDesc) {
|
|
59
68
|
descriptions.push(currentDesc);
|
|
@@ -105,6 +114,31 @@ function parseFieldContent(content, info) {
|
|
|
105
114
|
}
|
|
106
115
|
//#endregion
|
|
107
116
|
//#region src/node/markdown.ts
|
|
117
|
+
/**
|
|
118
|
+
* markdown-it plugin that registers `::: field` and `::: field-group` containers.
|
|
119
|
+
*
|
|
120
|
+
* Registers two container syntaxes:
|
|
121
|
+
* - `::: field-group` — wraps a group of fields in a `<div class="vp-field-group">`
|
|
122
|
+
* - `::: field` — parses the container body via `parseFieldContent` and renders
|
|
123
|
+
* a `<VPField>` Vue component with the extracted props
|
|
124
|
+
*
|
|
125
|
+
* markdown-it 插件,注册 `::: field` 和 `::: field-group` 容器。
|
|
126
|
+
*
|
|
127
|
+
* 注册两种容器语法:
|
|
128
|
+
* - `::: field-group` — 将一组字段包裹在 `<div class="vp-field-group">` 中
|
|
129
|
+
* - `::: field` — 通过 `parseFieldContent` 解析容器正文,并渲染带有提取属性的
|
|
130
|
+
* `<VPField>` Vue 组件
|
|
131
|
+
*
|
|
132
|
+
* @param md - The markdown-it instance to extend / 要扩展的 markdown-it 实例
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import MarkdownIt from 'markdown-it'
|
|
136
|
+
* import { fieldMarkdownPlugin } from 'vitepress-plugin-field/node'
|
|
137
|
+
*
|
|
138
|
+
* const md = new MarkdownIt()
|
|
139
|
+
* md.use(fieldMarkdownPlugin)
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
108
142
|
const fieldMarkdownPlugin = (md) => {
|
|
109
143
|
createContainerPlugin(md, "field-group", { before: () => "<div class=\"vp-field-group\">" });
|
|
110
144
|
createContainerSyntaxPlugin(md, "field", (tokens, idx, _, env) => {
|
|
@@ -115,6 +149,29 @@ const fieldMarkdownPlugin = (md) => {
|
|
|
115
149
|
};
|
|
116
150
|
//#endregion
|
|
117
151
|
//#region src/node/plugin.ts
|
|
152
|
+
/**
|
|
153
|
+
* VitePress plugin for rendering structured field documentation blocks.
|
|
154
|
+
*
|
|
155
|
+
* Registers a markdown-it container plugin that transforms `::: field` blocks
|
|
156
|
+
* into interactive `<VPField>` Vue components, and wires up the client-side
|
|
157
|
+
* component registration via `enhanceAppWithField`.
|
|
158
|
+
*
|
|
159
|
+
* VitePress 插件,用于渲染结构化的字段文档块。
|
|
160
|
+
*
|
|
161
|
+
* 注册 markdown-it 容器插件,将 `::: field` 块转换为交互式 `<VPField>` Vue 组件,
|
|
162
|
+
* 并通过 `enhanceAppWithField` 完成客户端组件注册。
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* `.vitepress/config.ts`
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { defineConfig } from 'vitepress-tuck'
|
|
168
|
+
* import field from 'vitepress-plugin-field'
|
|
169
|
+
*
|
|
170
|
+
* export default defineConfig({
|
|
171
|
+
* plugins: [field()],
|
|
172
|
+
* })
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
118
175
|
const field = definePlugin(() => ({
|
|
119
176
|
name: "vitepress-plugin-field",
|
|
120
177
|
client: { enhance: "enhanceAppWithField" },
|
|
@@ -124,6 +181,11 @@ const field = definePlugin(() => ({
|
|
|
124
181
|
}));
|
|
125
182
|
//#endregion
|
|
126
183
|
//#region src/node/index.ts
|
|
184
|
+
/**
|
|
185
|
+
* Node-side entry point for `vitepress-plugin-field`.
|
|
186
|
+
*
|
|
187
|
+
* `vitepress-plugin-field` 的 Node 端入口模块。
|
|
188
|
+
*/
|
|
127
189
|
var node_default = field;
|
|
128
190
|
//#endregion
|
|
129
191
|
export { node_default as default, field, fieldMarkdownPlugin };
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress-plugin-field",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "Render structured API fields and properties documentation in your VitePress site.",
|
|
6
6
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo/)",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"homepage": "https://tuck.pengzhanbo.cn/plugins/field",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "git+https://github.com/pengzhanbo/vitepress-tuck.git",
|
|
11
12
|
"directory": "packages/plugin-field"
|
|
12
13
|
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/pengzhanbo/vitepress-tuck/issues"
|
|
16
|
+
},
|
|
13
17
|
"keywords": [
|
|
14
18
|
"vitepress",
|
|
15
19
|
"vitepress-plugin",
|
|
@@ -34,8 +38,8 @@
|
|
|
34
38
|
},
|
|
35
39
|
"dependencies": {
|
|
36
40
|
"@pengzhanbo/utils": "^3.7.3",
|
|
37
|
-
"vitepress-plugin-toolkit": "0.
|
|
38
|
-
"vitepress-tuck": "0.
|
|
41
|
+
"vitepress-plugin-toolkit": "0.4.0",
|
|
42
|
+
"vitepress-tuck": "0.4.0"
|
|
39
43
|
},
|
|
40
44
|
"publishConfig": {
|
|
41
45
|
"access": "public",
|