Skip to content

Commit deadc61

Browse files
committed
docs: update doc for 'Directory Structure'
1 parent 3671b7f commit deadc61

File tree

2 files changed

+46
-88
lines changed

2 files changed

+46
-88
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
# Directory Structure
22

3-
## User Side
4-
5-
With following the principle of `Convention is superior to configuration`, the recommended document structure is as follows:
3+
VuePress follows the principle of **"Convention is better than configuration"**, the recommended document structure is as follows:
64

75
::: vue
86
.
97
├── docs
10-
│   ├── .vuepress (_**Optional**_)
11-
│   │   ├── `components` (_**Optional**_)
12-
│   │   ├── `theme` (_**Optional**_)
8+
│   ├── .vuepress _(**Optional**)_
9+
│   │   ├── `components` _(**Optional**)_
10+
│   │   ├── `theme` _(**Optional**)_
1311
│   │   │ └── Layout.vue
14-
│   │   ├── `public` (_**Optional**_)
15-
│   │   ├── `styles` (_**Optional**_)
12+
│   │   ├── `public` _(**Optional**)_
13+
│   │   ├── `styles` _(**Optional**)_
1614
│   │   │   ├── index.styl
1715
│   │   │   └── palette.styl
18-
│   │   ├── `emplates` (_**OptionalDanger Zone**_)
16+
│   │   ├── `emplates` _(**Optional, Danger Zone**)_
1917
│   │   │   ├── dev.html
2018
│   │   │   └── ssr.html
21-
│   │   ├── `config.js` (_**Optional**_)
22-
│   │   └── `enhanceApp.js` (_**Optional**_)
19+
│   │   ├── `config.js` _(**Optional**)_
20+
│   │   └── `enhanceApp.js` _(**Optional**)_
2321
│   │ 
2422
│   ├── README.md
2523
│   ├── guide
@@ -35,9 +33,9 @@ Please note the capitalization of the directory name.
3533

3634
- `docs/.vuepress`: It is used to store global configuration, components, static resources, etc.
3735
- `docs/.vuepress/components`: The Vue components in this directory will be automatically registered as global components.
38-
- `docs/.vuepress/theme`: Used to store local theme
36+
- `docs/.vuepress/theme`: Used to store local theme.
3937
- `docs/.vuepress/style`: Stores style related files.
40-
- `docs/.vuepress/style/index.styl`: Automatically imported global style files, generated at the end of the final file, have a higher priority than the default style.
38+
- `docs/.vuepress/style/index.styl`: Automatically applied global style files, generated at the ending of the CSS file, have a higher priority than the default style.
4139
- `docs/.vuepress/style/palette.styl`: The palette is used to override the default color constants and to set the color constants of Stylus.
4240
- `docs/.vuepress/public`: Static resource directory.
4341
- `docs/.vuepress/template`: Store HTML template files.
@@ -46,7 +44,9 @@ Please note the capitalization of the directory name.
4644
- `docs/.vuepress/config.js`: Entry file of configuration, can also be `yml` or `toml`.
4745
- `docs/.vuepress/enhanceApp.js`: App level enhancement.
4846

49-
In addition, for the directory structure above, the default page routing address is as follows:
47+
## Default Page Routing
48+
49+
For the above directory structure, the default page routing paths are as follows:
5050

5151
| Relative Path | Page Routing |
5252
|---|---|
@@ -56,6 +56,7 @@ In addition, for the directory structure above, the default page routing address
5656

5757
**Also see:**
5858

59-
- [Theme]()
60-
- [Config]()
59+
- [Config](../config/README.md)
60+
- [Theme](../theme/README.md)
61+
- [Default Theme Config](../theme/default-theme-config.md)
6162

Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
# 目录结构
22

3-
## 用户视角
4-
5-
VuePress 遵循 "约定优于于配置" 的原则,推荐的文档结构如下:
3+
VuePress 遵循 **“约定优于配置”** 的原则,推荐的目录结构如下:
64

75
::: vue
86
.
97
├── docs
10-
│   ├── .vuepress (_**Optional**_)
11-
│   │   ├── `components` (_**Optional**_)
12-
│   │   ├── `layouts` (_**Optional**_)
13-
│   │   │   └── xxx.vue
14-
│   │   ├── `theme` (_**Optional**_)
8+
│   ├── .vuepress _(**可选的**)_
9+
│   │   ├── `components` _(**可选的**)_
10+
│   │   ├── `theme` _(**可选的**)_
1511
│   │   │ └── Layout.vue
16-
│   │   ├── `public` (_**Optional**_)
17-
│   │   ├── `styles` (_**Optional**_)
12+
│   │   ├── `public` _(**可选的**)_
13+
│   │   ├── `styles` _(**可选的**)_
1814
│   │   │   ├── index.styl
1915
│   │   │   └── palette.styl
20-
│   │   ├── `emplates` (_**Optional,Danger Zone**_)
16+
│   │   ├── `emplates` _(**可选的, 谨慎配置**)_
2117
│   │   │   ├── dev.html
2218
│   │   │   └── ssr.html
23-
│   │   ├── `config.js` (_**Optional**_)
24-
│   │   └── `enhanceApp.js` (_**Optional**_)
19+
│   │   ├── `config.js` _(**可选的**)_
20+
│   │   └── `enhanceApp.js` _(**可选的**)_
2521
│   │ 
2622
│   ├── README.md
2723
│   ├── guide
@@ -32,74 +28,35 @@ VuePress 遵循 "约定优于于配置" 的原则,推荐的文档结构如下
3228
:::
3329

3430
::: warning 注意
35-
请留意目录名称的大小写
31+
请留意目录名的大写
3632
:::
3733

38-
39-
40-
如上,由 VuePress 约定的目录:
41-
4234
- `docs/.vuepress`: 用于存放全局的配置、组件、静态资源等。
43-
- `docs/.vuepress/components`: 该目录下的 Vue 组件会被自动注册为全局组件。
44-
- `docs/.vuepress/layouts`: 该目录下的 Vue 组件会被自动注册为布局组件。
35+
- `docs/.vuepress/components`: 该目录中的 Vue 组件将会被自动注册为全局组件。
4536
- `docs/.vuepress/theme`: 用于存放本地主题。
46-
- `docs/.vuepress/style`: 存放样式相关的文件
47-
- `docs/.vuepress/style/index.styl`: 自动被导入的全局样式文件,生成在最终文件的末尾,具有比默认样式更高的优先级。
48-
- `docs/.vuepress/style/palette.styl`: 调色板,用于覆盖默认的颜色常量,以及设定 Stylus 的颜色常量
37+
- `docs/.vuepress/style`: 用于存放样式相关的文件
38+
- `docs/.vuepress/style/index.styl`: 将会被自动应用的全局样式文件,会生成在最终的 CSS 文件结尾,具有比默认样式更高的优先级。
39+
- `docs/.vuepress/style/palette.styl`: 用于重写默认颜色常量,或者设置新的的 stylus 颜色常量
4940
- `docs/.vuepress/public`: 静态资源目录。
50-
- `docs/.vuepress/template`: 存放 HTML 模板文件。
51-
- `docs/.vuepress/template/dev.html`: 开发环境的 HTML 模板文件。
52-
- `docs/.vuepress/template/ssr.html`: 基于 Vue SSR 的构建阶段的 HTML 模板文件。
53-
- `docs/.vuepress/config.js`: 配置入口文件,也可以是 `yml``toml`
54-
- `docs/.vuepress/enhanceApp.js`: 应用级别的配置。
41+
- `docs/.vuepress/template`: 存储 HTML 模板文件。
42+
- `docs/.vuepress/template/dev.html`: 用于开发环境的 HTML 模板文件。
43+
- `docs/.vuepress/template/ssr.html`: 构建时基于 Vue SSR 的 HTML 模板文件。
44+
- `docs/.vuepress/config.js`: 配置文件的入口文件,也可以是 `YML``toml`
45+
- `docs/.vuepress/enhanceApp.js`: 客户端应用的增强。
46+
47+
**同时阅读:**
5548

56-
此外,对于上述的目录结构,默认情况下,生成的页面路由地址如下:
49+
- [配置](../config/README.md)
50+
- [主题](../theme/README.md)
51+
- [默认主题配置](../theme/default-theme-config.md)
5752

58-
| 相对路径 | 页面路由 |
53+
## 默认的页面路由
54+
55+
此外,对于上述的目录结构,默认页面路由地址如下:
56+
57+
| 文件的相对路径 | 页面路由地址 |
5958
|---|---|
6059
| `/README.md` | `/` |
6160
| `/guide/README.md` | `/guide/` |
6261
| `/config.md` | `/config.html` |
6362

64-
**Also see:**
65-
66-
- [Theme]()
67-
- [Config]()
68-
69-
## 主题视角
70-
71-
一个约定的主题目录结构和用户目录相似,它是这样的:
72-
73-
::: vue
74-
theme
75-
├── `components` (_**Optional**_)
76-
│ └── xxx.vue
77-
├── `layouts`
78-
│   ├── Layout.vue (_**Required**_)
79-
│   └── 404.vue (_**Optional**_)
80-
├── `styles` (_**Optional**_)
81-
│   ├── index.styl
82-
│   └── palette.styl
83-
├── `templates` (_**Optional**_)
84-
│   ├── dev.html
85-
│   └── ssr.html
86-
├── `index.js` (_**Optional**_)
87-
└── package.json
88-
:::
89-
90-
- `theme/components`: 主题的组件,不会被自动注册为全局组件,主题开发者可借助 `@vuepress/plugin-register-components` 来决定是否注册为全局组件。
91-
- `theme/layouts`: 主题的布局组件,其中 `Layout.vue` 为必需项。
92-
- `theme/style`: 同上。
93-
- `theme/template`: 同上。
94-
- `theme/index.js`: 主题配置的入口文件。
95-
96-
97-
一些要点:
98-
99-
1. 用户的 `palette.styl` 比主题的 `palette.styl` 优先级更高,因此,主题可以定义自己的调色板,同时用户又可以调节它。
100-
2. 用户的 `index.styl` 和主题的 `index.styl` 都会被生成到最终的 `CSS` 文件中,但是用户的样式会生成得更晚,因此具有更高的优先级。
101-
2. 对于模板,以 `ssr.html` 为例,若用户的 `ssr.html` 不存在,则降级到主题的 `ssr.html`,若主题的 `ssr.html` 也不存在,则降级到默认的 `ssr.html`
102-
103-
::: warning Note
104-
在自定义 `ssr.html``dev.html` 时,最好在默认的[模板文件](https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/app/index.dev.html)的基础上来修改,否则可能导致构建失败。
105-
:::

0 commit comments

Comments
 (0)