Skip to content

Commit 1833950

Browse files
committed
update
1 parent 6d5df34 commit 1833950

File tree

5 files changed

+821
-204
lines changed

5 files changed

+821
-204
lines changed

packages/vitepress-plugin-tree/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
},
1717
"files": [
1818
"dist",
19-
"readme.md"
19+
"readme.md",
20+
"tree.png"
2021
],
2122
"keywords": [
2223
"lite-tree",
@@ -28,5 +29,10 @@
2829
"license": "MIT",
2930
"dependencies": {
3031
"@lite-tree/vue": "workspace:*"
32+
},
33+
"devDependencies": {
34+
"@vue/tsconfig": "^0.5.1",
35+
"vite": "^5.4.4",
36+
"vue": "^3.5.4"
3137
}
3238
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# vitepress-plugin-tree
2+
3+
Easy to render tree in VitePress.
4+
5+
[document](https://zhangfisher.github.io/repos/#lite-tree)
6+
7+
`vitepress-plugin-tree`是一个`Vue`组件,用于渲染树形结构。
8+
9+
## Installation
10+
11+
```bash
12+
npm install vitepress-plugin-tree
13+
// or
14+
yarn add vitepress-plugin-tree
15+
// or
16+
pnpm add vitepress-plugin-tree
17+
```
18+
19+
## Usage
20+
21+
### Step 1: Configuration
22+
23+
In `./vitepress/config.mts` config :
24+
25+
```ts {5-9}
26+
// ./vitepress/config.mts
27+
import { defineConfig } from 'vitepress'
28+
29+
export default defineConfig({
30+
vue:{
31+
template: {
32+
compilerOptions: {
33+
whitespace: 'preserve'
34+
}
35+
}
36+
}
37+
})
38+
```
39+
40+
### Step 2: Register the component
41+
42+
Register `LiteTree` as a global component so that it can be used anywhere.
43+
44+
```ts
45+
// .vitepress/theme/index.js
46+
import DefaultTheme from 'vitepress/theme'
47+
import { LiteTree } from 'vitepress-plugin-tree'
48+
49+
/** @type {import('vitepress').Theme} */
50+
export default {
51+
extends: DefaultTheme,
52+
enhanceApp({ app }) {
53+
app.component('Tree'LiteTree)
54+
}
55+
}
56+
```
57+
58+
## Step 3: Render a tree
59+
60+
In markdown file, use `Tree` component to render tree.
61+
62+
```vue
63+
<Tree>
64+
Root
65+
A
66+
A1
67+
A2
68+
B
69+
B1
70+
B2
71+
</Tree>
72+
```
73+
74+
**Use `4 spaces` or `1 TAB` to represent a tree level.**
75+
76+
## Example
77+
78+
```md
79+
<LiteTree>
80+
#error=color:red;border: 1px solid red;background:#ffd2d2;padding:2px;
81+
#blue=color:red;border: 1px solid blue;background:#e6e6ff;padding:2px;
82+
airplane=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiB2aWV3Qm94PSIwIDAgMjU2IDI1NiI+PHBhdGggZmlsbD0iY3VycmVudENvbG9yIiBkPSJNMjM1LjU4IDEyOC44NEwxNjAgOTEuMDZWNDhhMzIgMzIgMCAwIDAtNjQgMHY0My4wNmwtNzUuNTggMzcuNzhBOCA4IDAgMCAwIDE2IDEzNnYzMmE4IDggMCAwIDAgOS41NyA3Ljg0TDk2IDE2MS43NnYxOC45M2wtMTMuNjYgMTMuNjVBOCA4IDAgMCAwIDgwIDIwMHYzMmE4IDggMCAwIDAgMTEgNy40M2wzNy0xNC44MWwzNyAxNC44MWE4IDggMCAwIDAgMTEtNy40M3YtMzJhOCA4IDAgMCAwLTIuMzQtNS42NkwxNjAgMTgwLjY5di0xOC45M2w3MC40MyAxNC4wOEE4IDggMCAwIDAgMjQwIDE2OHYtMzJhOCA4IDAgMCAwLTQuNDItNy4xNk0yMjQgMTU4LjI0bC03MC40My0xNC4wOEE4IDggMCAwIDAgMTQ0IDE1MnYzMmE4IDggMCAwIDAgMi4zNCA1LjY2TDE2MCAyMDMuMzF2MTYuODdsLTI5LTExLjYxYTggOCAwIDAgMC01Ljk0IDBMOTYgMjIwLjE4di0xNi44N2wxMy42Ni0xMy42NUE4IDggMCAwIDAgMTEyIDE4NHYtMzJhOCA4IDAgMCAwLTkuNTctNy44NEwzMiAxNTguMjR2LTE3LjNsNzUuNTgtMzcuNzhBOCA4IDAgMCAwIDExMiA5NlY0OGExNiAxNiAwIDAgMSAzMiAwdjQ4YTggOCAwIDAgMCA0LjQyIDcuMTZMMjI0IDE0MC45NFoiLz48L3N2Zz4=
83+
ts=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiB2aWV3Qm94PSIwIDAgMTUgMTUiPjxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBkPSJNMTIuNSA4di0uMTY3YzAtLjczNi0uNTk3LTEuMzMzLTEuMzMzLTEuMzMzSDEwYTEuNSAxLjUgMCAxIDAgMCAzaDFhMS41IDEuNSAwIDAgMSAwIDNoLTFBMS41IDEuNSAwIDAgMSA4LjUgMTFNOCA2LjVIM20yLjUgMFYxM00uNS41aDE0djE0SC41eiIvPjwvc3ZnPg==
84+
---
85+
- [airplane]Company A({color:red;}Key,{#blue}Urgent) // Company Name
86+
Administrative Center
87+
{color:red;font-weight:bold;background:#ffeaea}President's Office
88+
[checked]Human Resources Department
89+
[unchecked]{.blue}Finance Department
90+
Administrative Department //+ Responsible for administrative management
91+
Legal Department //+ Litigation, etc.
92+
[airplane]Audit Department //+ Audit finance[Save:tag](sss) [Link](sss)
93+
Information Center // Key[Save](www.baidu.com)[tag][Link:tag](www.baidu.com)
94+
[star]Sec[star]ur[star]ity[star] and [star]Pro[star]tection[star] Department[star] //{color:red} Confidentiality work
95+
+ Market Center
96+
Marketing Department({#error}Error,"{#warning}Warning")
97+
Sales Department //-
98+
Customer Service Department //-
99+
{#blue}Brand Department // this is cool
100+
Market Planning Department //! Key
101+
Market Marketing Department // {.blue}this is cool
102+
R&D Center
103+
Mobile R&D Department //!
104+
Platform R&D Department({success}Java,{error}Go)
105+
{.success}Testing Department
106+
Operations Department
107+
Product Department //*
108+
Design Department //*
109+
Project Management Department //*
110+
</LiteTree>
111+
112+
```
113+
114+
**Rendered effect:**
115+
116+
![](./tree.png)
117+
118+
119+
See [document](https://zhangfisher.github.io/repos/#lite-tree)
120+
121+
122+
123+
124+
97.3 KB
Loading

packages/vitepress-plugin-tree/vite.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import dts from 'vite-plugin-dts';
1010
// https://vitejs.dev/config/
1111
export default defineConfig({
1212
plugins: [
13-
vue(),
13+
vue(),
14+
StyleBundler(),
15+
VueDevTools(),
1416
dts({rollupTypes: true})
1517
],
1618
resolve: {

0 commit comments

Comments
 (0)