Skip to content

Commit 71a3dd4

Browse files
committed
update docs
1 parent 8ea2e64 commit 71a3dd4

File tree

6 files changed

+168
-166
lines changed

6 files changed

+168
-166
lines changed

docs/.vitepress/config.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ export default defineConfig({
88
// https://vitepress.dev/reference/default-theme-config
99
nav: [
1010
{ text: 'Home', link: '/' },
11-
{ text: 'Examples', link: '/markdown-examples' }
11+
{ text: 'Vue Example', link: '/vue-example' },
12+
{ text: 'Vitepress Example', link: '/vitepress-example' },
1213
],
1314

1415
sidebar: [
1516
{
1617
text: 'Examples',
1718
items: [
18-
{ text: 'Markdown Examples', link: '/markdown-examples' },
19-
{ text: 'Runtime API Examples', link: '/api-examples' }
19+
{ text: 'Vue Example', link: '/vue-example' },
20+
{ text: 'Vitepress Example', link: '/vitepress-example' },
2021
]
2122
}
2223
],
2324

2425
socialLinks: [
25-
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
26+
{ icon: 'github', link: 'https://github.com/tlylt/vue-tree' }
2627
]
2728
},
2829
vue: {

docs/api-examples.md

-65
This file was deleted.

docs/index.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@ layout: home
44

55
hero:
66
name: "@tlylt/vue-tree"
7-
text: "@tlylt/vue-tree"
8-
tagline: My great project tagline
7+
text: ""
8+
tagline: A Simple Vue Component to Help Visualize Your Tree Structures
99
actions:
1010
- theme: brand
11-
text: Markdown Examples
12-
link: /markdown-examples
11+
text: Vue Example
12+
link: /vue-example
1313
- theme: alt
14-
text: API Examples
15-
link: /api-examples
14+
text: Vitepress Example
15+
link: /vitepress-example
1616

1717
features:
18-
- title: Feature A
19-
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
20-
- title: Feature B
21-
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
22-
- title: Feature C
23-
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
18+
- title: Use spaces to indicate nesting
19+
details: vue-tree will convert the spaces into tokens that visualize the nesting levels
20+
- title: Customize the look
21+
details: Customize the look
2422
---

docs/markdown-examples.md

-85
This file was deleted.

docs/vitepress-example.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# Vitepress Example
6+
7+
## Installation
8+
Install the package via npm:
9+
10+
```bash
11+
npm install @tlylt/vue-tree
12+
```
13+
14+
or yarn:
15+
16+
```bash
17+
yarn add @tlylt/vue-tree
18+
```
19+
20+
## Configuration
21+
22+
In your `.vitepress/config.ts`:
23+
24+
```ts
25+
export default defineConfig({
26+
// ...
27+
vue: {
28+
// @vitejs/plugin-vue options
29+
template: {
30+
compilerOptions: {
31+
whitespace: "preserve",
32+
},
33+
}
34+
}
35+
})
36+
```
37+
38+
## Code
39+
40+
```vue
41+
<script setup>
42+
import { VueTree } from '@tlylt/vue-tree'
43+
import '@tlylt/vue-tree/style.css'
44+
</script>
45+
46+
<VueTree>
47+
C:/course/
48+
textbook/
49+
index.md
50+
index.md
51+
reading.md
52+
site.json
53+
</VueTree>
54+
```
55+
56+
## Rendered
57+
58+
<script setup>
59+
import { VueTree } from '../src/index'
60+
// import { VueTree } from '@tlylt/vue-tree'
61+
// import '@tlylt/vue-tree/style.css'
62+
</script>
63+
64+
<VueTree>
65+
C:/course/
66+
textbook/
67+
index.md
68+
index.md
69+
reading.md
70+
site.json
71+
</VueTree>

docs/vue-example.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Vue Example
2+
3+
## Installation
4+
Install the package via npm:
5+
6+
```bash
7+
npm install @tlylt/vue-tree
8+
```
9+
10+
or yarn:
11+
12+
```bash
13+
yarn add @tlylt/vue-tree
14+
```
15+
16+
## Configuration
17+
To ensure proper rendering of the tree structure, you need to configure the Vue compiler to preserve whitespace. Update your `vite.config.ts` as follows:
18+
19+
```ts
20+
// https://vite.dev/config/
21+
export default defineConfig({
22+
// ...
23+
plugins: [vue(
24+
{
25+
template: {
26+
compilerOptions: {
27+
whitespace: "preserve",
28+
},
29+
}
30+
}
31+
)],
32+
})
33+
```
34+
35+
## Code
36+
You can locally register the `VueTree` component in your Vue file:
37+
38+
```vue
39+
<script setup lang="ts">
40+
import { VueTree } from '@tlylt/vue-tree'
41+
import '@tlylt/vue-tree/style.css'
42+
</script>
43+
44+
<template>
45+
<VueTree>
46+
C:/course/
47+
textbook/
48+
index.md
49+
index.md
50+
reading.md
51+
site.json
52+
</VueTree>
53+
</template>
54+
```
55+
56+
Alternatively, you can register the `VueTree` component globally in your `main.ts`:
57+
58+
```ts
59+
import { createApp } from 'vue';
60+
import App from './App.vue';
61+
import { VueTree } from '@tlylt/vue-tree';
62+
import '@tlylt/vue-tree/style.css'; // Import the styles
63+
64+
const app = createApp(App);
65+
app.use(VueTree);
66+
app.mount('#app');
67+
```
68+
69+
## Rendered
70+
71+
<script setup>
72+
import { VueTree } from '../src/index'
73+
</script>
74+
75+
<VueTree>
76+
C:/course/
77+
textbook/
78+
index.md
79+
index.md
80+
reading.md
81+
site.json
82+
</VueTree>

0 commit comments

Comments
 (0)