vitepress-plugin-file-tree 0.2.0 → 0.3.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.js +2 -2
- package/dist/client/ssr/index.js +2 -2
- package/dist/node/index.d.ts +33 -31
- package/dist/node/index.js +30 -25
- package/package.json +3 -3
|
@@ -7,7 +7,7 @@ const _hoisted_2$1 = {
|
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "vp-file-tree-title"
|
|
9
9
|
};
|
|
10
|
-
const _sfc_main =
|
|
10
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
11
11
|
__name: "VPFileTree",
|
|
12
12
|
props: {
|
|
13
13
|
title: {},
|
|
@@ -36,7 +36,7 @@ const _hoisted_4 = {
|
|
|
36
36
|
key: 0,
|
|
37
37
|
class: "group"
|
|
38
38
|
};
|
|
39
|
-
const _sfc_main$1 =
|
|
39
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
40
40
|
__name: "VPFileTreeNode",
|
|
41
41
|
props: {
|
|
42
42
|
type: {},
|
package/dist/client/ssr/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { computed, defineComponent, inject, mergeProps, ref, unref, useSSRContex
|
|
|
2
2
|
import { ssrInterpolate, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderSlot, ssrRenderStyle } from "vue/server-renderer";
|
|
3
3
|
import { VPCopyButton } from "vitepress-plugin-toolkit/client";
|
|
4
4
|
//#region src/client/VPFileTree.vue
|
|
5
|
-
const _sfc_main =
|
|
5
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
6
6
|
__name: "VPFileTree",
|
|
7
7
|
__ssrInlineRender: true,
|
|
8
8
|
props: {
|
|
@@ -29,7 +29,7 @@ _sfc_main.setup = (props, ctx) => {
|
|
|
29
29
|
};
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/client/VPFileTreeNode.vue
|
|
32
|
-
const _sfc_main$1 =
|
|
32
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
33
33
|
__name: "VPFileTreeNode",
|
|
34
34
|
__ssrInlineRender: true,
|
|
35
35
|
props: {
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import { PluginSimple } from "markdown-it";
|
|
2
2
|
|
|
3
|
-
//#region src/node/
|
|
4
|
-
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* import { fileTreeMarkdownPlugin } from 'vitepress-plugin-file-tree'
|
|
8
|
-
* import { defineConfig } from 'vitepress'
|
|
9
|
-
* export default defineConfig({
|
|
10
|
-
* markdown: {
|
|
11
|
-
* config: (md) => {
|
|
12
|
-
* md.use(fileTreeMarkdownPlugin)
|
|
13
|
-
* },
|
|
14
|
-
* },
|
|
15
|
-
* })
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
declare const fileTreeMarkdownPlugin: PluginSimple;
|
|
3
|
+
//#region src/node/plugin.d.ts
|
|
4
|
+
declare const fileTree: (options?: unknown) => import("vitepress-tuck").VitepressPlugin;
|
|
19
5
|
//#endregion
|
|
20
6
|
//#region src/node/types.d.ts
|
|
21
7
|
/**
|
|
@@ -42,16 +28,7 @@ interface FileTreeAttrs {
|
|
|
42
28
|
title?: string;
|
|
43
29
|
}
|
|
44
30
|
//#endregion
|
|
45
|
-
//#region src/node/
|
|
46
|
-
/**
|
|
47
|
-
* Parse the content from the `::: file-tree` container into a node tree structure.
|
|
48
|
-
*
|
|
49
|
-
* 从 `::: file-tree` 容器中解析内容为节点树结构
|
|
50
|
-
*
|
|
51
|
-
* @param content - Raw file tree text content / 文件树的原始文本内容
|
|
52
|
-
* @returns File tree node array / 文件树节点数组
|
|
53
|
-
*/
|
|
54
|
-
declare function parseContentWithContainer(content: string): FileTreeNode[];
|
|
31
|
+
//#region src/node/fileTreeToCMDText.d.ts
|
|
55
32
|
/**
|
|
56
33
|
* Convert file tree to command line text format
|
|
57
34
|
*
|
|
@@ -63,7 +40,35 @@ declare function parseContentWithContainer(content: string): FileTreeNode[];
|
|
|
63
40
|
*/
|
|
64
41
|
declare function fileTreeToCMDText(nodes: FileTreeNode[], prefix?: string): string;
|
|
65
42
|
//#endregion
|
|
66
|
-
//#region src/node/
|
|
43
|
+
//#region src/node/markdown.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { fileTreeMarkdownPlugin } from 'vitepress-plugin-file-tree'
|
|
48
|
+
* import { defineConfig } from 'vitepress'
|
|
49
|
+
* export default defineConfig({
|
|
50
|
+
* markdown: {
|
|
51
|
+
* config: (md) => {
|
|
52
|
+
* md.use(fileTreeMarkdownPlugin)
|
|
53
|
+
* },
|
|
54
|
+
* },
|
|
55
|
+
* })
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare const fileTreeMarkdownPlugin: PluginSimple;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/node/parseContentWithContainer.d.ts
|
|
61
|
+
/**
|
|
62
|
+
* Parse the content from the `::: file-tree` container into a node tree structure.
|
|
63
|
+
*
|
|
64
|
+
* 从 `::: file-tree` 容器中解析内容为节点树结构
|
|
65
|
+
*
|
|
66
|
+
* @param content - Raw file tree text content / 文件树的原始文本内容
|
|
67
|
+
* @returns File tree node array / 文件树节点数组
|
|
68
|
+
*/
|
|
69
|
+
declare function parseContentWithContainer(content: string): FileTreeNode[];
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/node/parseContentWithFence.d.ts
|
|
67
72
|
/**
|
|
68
73
|
* Parse `tree` command output format into a structured file tree node array.
|
|
69
74
|
*
|
|
@@ -97,7 +102,4 @@ declare function parseContentWithFence(content: string): FileTreeNode[];
|
|
|
97
102
|
*/
|
|
98
103
|
declare function parseNodeInfo(info: string): Omit<FileTreeNode, 'children' | 'level'>;
|
|
99
104
|
//#endregion
|
|
100
|
-
|
|
101
|
-
declare const _default: (option?: unknown) => import("vitepress-tuck").VitepressPlugin;
|
|
102
|
-
//#endregion
|
|
103
|
-
export { FileTreeAttrs, FileTreeNode, _default as default, fileTreeMarkdownPlugin, fileTreeToCMDText, parseContentWithContainer, parseContentWithFence, parseNodeInfo };
|
|
105
|
+
export { FileTreeAttrs, FileTreeNode, fileTree as default, fileTree, fileTreeMarkdownPlugin, fileTreeToCMDText, parseContentWithContainer, parseContentWithFence, parseNodeInfo };
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { definePlugin } from "vitepress-tuck";
|
|
2
2
|
import { createContainerSyntaxPlugin, stringifyAttrs } from "vitepress-plugin-toolkit";
|
|
3
3
|
import { removeTrailingSlash } from "@pengzhanbo/utils";
|
|
4
|
+
//#region src/node/fileTreeToCMDText.ts
|
|
5
|
+
/**
|
|
6
|
+
* Convert file tree to command line text format
|
|
7
|
+
*
|
|
8
|
+
* 将文件树转换为命令行文本格式
|
|
9
|
+
*
|
|
10
|
+
* @param nodes - File tree nodes / 文件树节点
|
|
11
|
+
* @param prefix - Line prefix / 行前缀
|
|
12
|
+
* @returns CMD text / CMD 文本
|
|
13
|
+
*/
|
|
14
|
+
function fileTreeToCMDText(nodes, prefix = "") {
|
|
15
|
+
let content = prefix ? "" : ".\n";
|
|
16
|
+
for (let i = 0, l = nodes.length; i < l; i++) {
|
|
17
|
+
const { filename, children } = nodes[i];
|
|
18
|
+
content += `${prefix + (i === l - 1 ? "└── " : "├── ")}${filename}\n`;
|
|
19
|
+
const child = children.filter((n) => n.filename !== "…");
|
|
20
|
+
if (child.length) content += fileTreeToCMDText(child, prefix + (i === l - 1 ? " " : "│ "));
|
|
21
|
+
}
|
|
22
|
+
return content;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
4
25
|
//#region src/node/parseNodeInfo.ts
|
|
5
26
|
/**
|
|
6
27
|
* Regex for focus marker
|
|
@@ -56,7 +77,7 @@ function parseNodeInfo(info) {
|
|
|
56
77
|
};
|
|
57
78
|
}
|
|
58
79
|
//#endregion
|
|
59
|
-
//#region src/node/
|
|
80
|
+
//#region src/node/parseContentWithContainer.ts
|
|
60
81
|
/**
|
|
61
82
|
* Parse the content from the `::: file-tree` container into a node tree structure.
|
|
62
83
|
*
|
|
@@ -90,27 +111,8 @@ function parseContentWithContainer(content) {
|
|
|
90
111
|
}
|
|
91
112
|
return root.children;
|
|
92
113
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Convert file tree to command line text format
|
|
95
|
-
*
|
|
96
|
-
* 将文件树转换为命令行文本格式
|
|
97
|
-
*
|
|
98
|
-
* @param nodes - File tree nodes / 文件树节点
|
|
99
|
-
* @param prefix - Line prefix / 行前缀
|
|
100
|
-
* @returns CMD text / CMD 文本
|
|
101
|
-
*/
|
|
102
|
-
function fileTreeToCMDText(nodes, prefix = "") {
|
|
103
|
-
let content = prefix ? "" : ".\n";
|
|
104
|
-
for (let i = 0, l = nodes.length; i < l; i++) {
|
|
105
|
-
const { filename, children } = nodes[i];
|
|
106
|
-
content += `${prefix + (i === l - 1 ? "└── " : "├── ")}${filename}\n`;
|
|
107
|
-
const child = children.filter((n) => n.filename !== "…");
|
|
108
|
-
if (child.length) content += fileTreeToCMDText(child, prefix + (i === l - 1 ? " " : "│ "));
|
|
109
|
-
}
|
|
110
|
-
return content;
|
|
111
|
-
}
|
|
112
114
|
//#endregion
|
|
113
|
-
//#region src/node/
|
|
115
|
+
//#region src/node/parseContentWithFence.ts
|
|
114
116
|
/**
|
|
115
117
|
* Regex for matching a single line of `tree` command output.
|
|
116
118
|
*
|
|
@@ -175,7 +177,7 @@ function parseContentWithFence(content) {
|
|
|
175
177
|
return root.children;
|
|
176
178
|
}
|
|
177
179
|
//#endregion
|
|
178
|
-
//#region src/node/
|
|
180
|
+
//#region src/node/markdown.ts
|
|
179
181
|
/**
|
|
180
182
|
* @example
|
|
181
183
|
* ```ts
|
|
@@ -239,8 +241,8 @@ ${renderedComment}${children.length > 0 ? renderFileTree(children, meta) : ""}
|
|
|
239
241
|
};
|
|
240
242
|
};
|
|
241
243
|
//#endregion
|
|
242
|
-
//#region src/node/
|
|
243
|
-
|
|
244
|
+
//#region src/node/plugin.ts
|
|
245
|
+
const fileTree = definePlugin(() => ({
|
|
244
246
|
name: "vitepress-plugin-file-tree",
|
|
245
247
|
client: { enhance: "enhanceAppWithFileTree" },
|
|
246
248
|
markdown: { config: (md) => {
|
|
@@ -252,4 +254,7 @@ var node_default = definePlugin(() => ({
|
|
|
252
254
|
}
|
|
253
255
|
}));
|
|
254
256
|
//#endregion
|
|
255
|
-
|
|
257
|
+
//#region src/node/index.ts
|
|
258
|
+
var node_default = fileTree;
|
|
259
|
+
//#endregion
|
|
260
|
+
export { node_default as default, fileTree, fileTreeMarkdownPlugin, fileTreeToCMDText, parseContentWithContainer, parseContentWithFence, parseNodeInfo };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress-plugin-file-tree",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "Render file tree structure in your VitePress site.",
|
|
6
6
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@pengzhanbo/utils": "^3.7.3",
|
|
37
37
|
"@vueuse/core": "^14.3.0",
|
|
38
|
-
"vitepress-plugin-toolkit": "0.
|
|
39
|
-
"vitepress-tuck": "0.
|
|
38
|
+
"vitepress-plugin-toolkit": "0.3.0",
|
|
39
|
+
"vitepress-tuck": "0.3.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public",
|