Skip to content

Commit bb5ba6e

Browse files
committed
docs: reorganize nav
1 parent 713bd26 commit bb5ba6e

33 files changed

+130
-112
lines changed

Diff for: docs/.vuepress/config.js

+102-94
Original file line numberDiff line numberDiff line change
@@ -23,123 +23,131 @@ module.exports = {
2323
editLinkText: 'Edit this page on GitHub',
2424
nav: [
2525
{
26-
text: 'Getting Started',
27-
link: '/essentials/getting-started'
26+
text: 'Guide',
27+
link: '/guide/'
2828
},
2929
{
3030
text: 'API Reference',
31-
link: '/api/options'
31+
link: '/api/'
3232
},
3333
{
3434
text: 'Release Notes',
35-
link: 'https://github.com/vuejs/vue-router/releasess'
35+
link: 'https://github.com/vuejs/vue-router/releases'
3636
}
3737
],
38-
sidebar: [
39-
'/installation.md',
40-
'/',
41-
{
42-
title: 'Essentials',
43-
collapsable: false,
44-
children: [
45-
'/essentials/getting-started.md',
46-
'/essentials/dynamic-matching.md',
47-
'/essentials/nested-routes.md',
48-
'/essentials/navigation.md',
49-
'/essentials/named-routes.md',
50-
'/essentials/named-views.md',
51-
'/essentials/redirect-and-alias.md',
52-
'/essentials/passing-props.md',
53-
'/essentials/history-mode.md'
54-
]
55-
},
56-
{
57-
title: 'Advanced',
58-
collapsable: false,
59-
children: [
60-
'/advanced/navigation-guards.md',
61-
'/advanced/meta.md',
62-
'/advanced/transitions.md',
63-
'/advanced/data-fetching.md',
64-
'/advanced/scroll-behavior.md',
65-
'/advanced/lazy-loading.md'
66-
]
67-
},
68-
{
69-
title: 'API Reference',
70-
collapsable: false,
71-
children: [
72-
'/api/options.md',
73-
'/api/router-instance.md',
74-
'/api/route-object.md',
75-
'/api/component-injections.md',
76-
'/api/router-link.md',
77-
'/api/router-view.md'
78-
]
79-
}
80-
]
38+
sidebar: {
39+
'/api/': [
40+
{
41+
title: 'API Reference',
42+
collapsable: false,
43+
children: [
44+
'/api/options.md',
45+
'/api/router-instance.md',
46+
'/api/route-object.md',
47+
'/api/component-injections.md',
48+
'/api/router-link.md',
49+
'/api/router-view.md'
50+
]
51+
}
52+
],
53+
'/': [
54+
'/installation.md',
55+
'/',
56+
{
57+
title: 'Essentials',
58+
collapsable: false,
59+
children: [
60+
'/guide/essentials/getting-started.md',
61+
'/guide/essentials/dynamic-matching.md',
62+
'/guide/essentials/nested-routes.md',
63+
'/guide/essentials/navigation.md',
64+
'/guide/essentials/named-routes.md',
65+
'/guide/essentials/named-views.md',
66+
'/guide/essentials/redirect-and-alias.md',
67+
'/guide/essentials/passing-props.md',
68+
'/guide/essentials/history-mode.md'
69+
]
70+
},
71+
{
72+
title: 'Advanced',
73+
collapsable: false,
74+
children: [
75+
'/guide/advanced/navigation-guards.md',
76+
'/guide/advanced/meta.md',
77+
'/guide/advanced/transitions.md',
78+
'/guide/advanced/data-fetching.md',
79+
'/guide/advanced/scroll-behavior.md',
80+
'/guide/advanced/lazy-loading.md'
81+
]
82+
}
83+
]
84+
}
8185
},
8286
'/zh/': {
8387
label: '简体中文',
8488
selectText: '选择语言',
8589
editLinkText: '在 GitHub 上编辑此页',
8690
nav: [
8791
{
88-
text: '起步',
89-
link: '/zh/essentials/getting-started'
92+
text: '指南',
93+
link: '/zh/guide/'
9094
},
9195
{
9296
text: 'API 参考',
93-
link: '/zh/api/options'
97+
link: '/zh/api/'
9498
},
9599
{
96100
text: '更新记录',
97-
link: 'https://github.com/vuejs/vue-router/releasess'
101+
link: 'https://github.com/vuejs/vue-router/releases'
98102
}
99103
],
100-
sidebar: [
101-
'/zh/installation.md',
102-
'/zh/',
103-
{
104-
title: '基础',
105-
collapsable: false,
106-
children: [
107-
'/zh/essentials/getting-started.md',
108-
'/zh/essentials/dynamic-matching.md',
109-
'/zh/essentials/nested-routes.md',
110-
'/zh/essentials/navigation.md',
111-
'/zh/essentials/named-routes.md',
112-
'/zh/essentials/named-views.md',
113-
'/zh/essentials/redirect-and-alias.md',
114-
'/zh/essentials/passing-props.md',
115-
'/zh/essentials/history-mode.md'
116-
]
117-
},
118-
{
119-
title: '进阶',
120-
collapsable: false,
121-
children: [
122-
'/zh/advanced/navigation-guards.md',
123-
'/zh/advanced/meta.md',
124-
'/zh/advanced/transitions.md',
125-
'/zh/advanced/data-fetching.md',
126-
'/zh/advanced/scroll-behavior.md',
127-
'/zh/advanced/lazy-loading.md'
128-
]
129-
},
130-
{
131-
title: 'API 参考',
132-
collapsable: false,
133-
children: [
134-
'/zh/api/options.md',
135-
'/zh/api/router-instance.md',
136-
'/zh/api/route-object.md',
137-
'/zh/api/component-injections.md',
138-
'/zh/api/router-link.md',
139-
'/zh/api/router-view.md'
140-
]
141-
}
142-
]
104+
sidebar: {
105+
'/zh/api/': [
106+
{
107+
title: 'API 参考',
108+
collapsable: false,
109+
children: [
110+
'/zh/api/options.md',
111+
'/zh/api/router-instance.md',
112+
'/zh/api/route-object.md',
113+
'/zh/api/component-injections.md',
114+
'/zh/api/router-link.md',
115+
'/zh/api/router-view.md'
116+
]
117+
}
118+
],
119+
'/zh/': [
120+
'/zh/installation.md',
121+
'/zh/',
122+
{
123+
title: '基础',
124+
collapsable: false,
125+
children: [
126+
'/zh/guide/essentials/getting-started.md',
127+
'/zh/guide/essentials/dynamic-matching.md',
128+
'/zh/guide/essentials/nested-routes.md',
129+
'/zh/guide/essentials/navigation.md',
130+
'/zh/guide/essentials/named-routes.md',
131+
'/zh/guide/essentials/named-views.md',
132+
'/zh/guide/essentials/redirect-and-alias.md',
133+
'/zh/guide/essentials/passing-props.md',
134+
'/zh/guide/essentials/history-mode.md'
135+
]
136+
},
137+
{
138+
title: '进阶',
139+
collapsable: false,
140+
children: [
141+
'/zh/guide/advanced/navigation-guards.md',
142+
'/zh/guide/advanced/meta.md',
143+
'/zh/guide/advanced/transitions.md',
144+
'/zh/guide/advanced/data-fetching.md',
145+
'/zh/guide/advanced/scroll-behavior.md',
146+
'/zh/guide/advanced/lazy-loading.md'
147+
]
148+
}
149+
]
150+
}
143151
}
144152
}
145153
}

Diff for: docs/.vuepress/enhanceApp.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default ({ router }) => {
2+
router.addRoutes([
3+
{ path: '/guide/', redirect: '/guide/essentials/getting-started.html' },
4+
{ path: '/:lang/guide/', redirect: '/:lang/guide/essentials/getting-started.html' },
5+
{ path: '/api/', redirect: '/api/options.html' },
6+
{ path: '/:lang/api/', redirect: '/:lang/api/options.html' }
7+
])
8+
}

Diff for: docs/.vuepress/public/_redirects

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# redirect old urls to root
2+
3+
/en/essentials/* /guide/essentials/*
4+
/en/advanced/* /guide/advanced/*
25
/en/* /:splat
6+
7+
/zh-cn/essentials/* /zh/guide/essentials/*
8+
/zh-cn/advanced/* /zh/guide/advanced/*
39
/zh-cn/* /zh/:splat
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: docs/advanced/navigation-guards.md renamed to docs/guide/advanced/navigation-guards.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Global before guards are called in creation order, whenever a navigation is trig
2020

2121
Every guard function receives three arguments:
2222

23-
- **`to: Route`**: the target [Route Object](../api/route-object.md) being navigated to.
23+
- **`to: Route`**: the target [Route Object](../../api/route-object.md) being navigated to.
2424

2525
- **`from: Route`**: the current route being navigated away from.
2626

@@ -30,9 +30,9 @@ Every guard function receives three arguments:
3030

3131
- **`next(false)`**: abort the current navigation. If the browser URL was changed (either manually by the user or via back button), it will be reset to that of the `from` route.
3232

33-
- **`next('/')` or `next({ path: '/' })`**: redirect to a different location. The current navigation will be aborted and a new one will be started. You can pass any location object to `next`, which allows you to specify options like `replace: true`, `name: 'home'` and any option used in [`router-link`'s `to` prop](../api/router-link.md) or [`router.push`](../api/router-instance.md#methods)
33+
- **`next('/')` or `next({ path: '/' })`**: redirect to a different location. The current navigation will be aborted and a new one will be started. You can pass any location object to `next`, which allows you to specify options like `replace: true`, `name: 'home'` and any option used in [`router-link`'s `to` prop](../../api/router-link.md) or [`router.push`](../../api/router-instance.md#methods)
3434

35-
- **`next(error)`**: (2.4.0+) if the argument passed to `next` is an instance of `Error`, the navigation will be aborted and the error will be passed to callbacks registered via [`router.onError()`](../api/router-instance.html#methods).
35+
- **`next(error)`**: (2.4.0+) if the argument passed to `next` is an instance of `Error`, the navigation will be aborted and the error will be passed to callbacks registered via [`router.onError()`](../../api/router-instance.html#methods).
3636

3737
**Make sure to always call the `next` function, otherwise the hook will never be resolved.**
3838

File renamed without changes.
File renamed without changes.

Diff for: docs/essentials/dynamic-matching.md renamed to docs/guide/essentials/dynamic-matching.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ You can have multiple dynamic segments in the same route, and they will map to c
3434
| /user/:username | /user/evan | `{ username: 'evan' }` |
3535
| /user/:username/post/:post_id | /user/evan/post/123 | `{ username: 'evan', post_id: 123 }` |
3636

37-
In addition to `$route.params`, the `$route` object also exposes other useful information such as `$route.query` (if there is a query in the URL), `$route.hash`, etc. You can check out the full details in the [API Reference](../api/route-object.md).
37+
In addition to `$route.params`, the `$route` object also exposes other useful information such as `$route.query` (if there is a query in the URL), `$route.hash`, etc. You can check out the full details in the [API Reference](../../api/route-object.md).
3838

3939
## Reacting to Params Changes
4040

Diff for: docs/essentials/getting-started.md renamed to docs/guide/essentials/getting-started.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
::: tip Note
44
We will be using [ES2015](https://github.com/lukehoban/es6features) in the code samples in the guide.
5+
6+
Also, all examples will be using the full version of Vue to make on-the-fly template compilation possible. See more details [here](https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only).
57
:::
68

79
Creating a Single-page Application with Vue + Vue Router is dead simple. With Vue.js, we are already composing our application with components. When adding Vue Router to the mix, all we need to do is map our components to the routes and let Vue Router know where to render them. Here's a basic example:
810

9-
::: tip Note
10-
All examples will be using the full version of Vue to make template parsing possible. See more details [here](https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only).
11-
:::
12-
1311
## HTML
1412

1513
``` html
@@ -94,4 +92,4 @@ Throughout the docs, we will often use the `router` instance. Keep in mind that
9492

9593
You can also check out this example [live](https://jsfiddle.net/yyx990803/xgrjzsup/).
9694

97-
Notice that a `<router-link>` automatically gets the `.router-link-active` class when its target route is matched. You can learn more about it in its [API reference](../api/router-link.md).
95+
Notice that a `<router-link>` automatically gets the `.router-link-active` class when its target route is matched. You can learn more about it in its [API reference](../../api/router-link.md).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: docs/zh/advanced/navigation-guards.md renamed to docs/zh/guide/advanced/navigation-guards.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ router.beforeEach((to, from, next) => {
2424

2525
每个守卫方法接收三个参数:
2626

27-
- **`to: Route`**: 即将要进入的目标 [路由对象](../api/route-object.md)
27+
- **`to: Route`**: 即将要进入的目标 [路由对象](../../api/route-object.md)
2828

2929
- **`from: Route`**: 当前导航正要离开的路由
3030

@@ -34,9 +34,9 @@ router.beforeEach((to, from, next) => {
3434

3535
- **`next(false)`**: 中断当前的导航。如果浏览器的 URL 改变了 (可能是用户手动或者浏览器后退按钮),那么 URL 地址会重置到 `from` 路由对应的地址。
3636

37-
- **`next('/')` 或者 `next({ path: '/' })`**: 跳转到一个不同的地址。当前的导航被中断,然后进行一个新的导航。你可以向 `next` 传递任意位置对象,且允许设置诸如 `replace: true``name: 'home'` 之类的选项以及任何用在 [`router-link``to` prop](../api/router-link.md)[`router.push`](../api/router-instance.md#方法) 中的选项。
37+
- **`next('/')` 或者 `next({ path: '/' })`**: 跳转到一个不同的地址。当前的导航被中断,然后进行一个新的导航。你可以向 `next` 传递任意位置对象,且允许设置诸如 `replace: true``name: 'home'` 之类的选项以及任何用在 [`router-link``to` prop](../../api/router-link.md)[`router.push`](../../api/router-instance.md#方法) 中的选项。
3838

39-
- **`next(error)`**: (2.4.0+) 如果传入 `next` 的参数是一个 `Error` 实例,则导航会被终止且该错误会被传递给 [`router.onError()`](../api/router-instance.html#方法) 注册过的回调。
39+
- **`next(error)`**: (2.4.0+) 如果传入 `next` 的参数是一个 `Error` 实例,则导航会被终止且该错误会被传递给 [`router.onError()`](../../api/router-instance.html#方法) 注册过的回调。
4040

4141
**确保要调用 `next` 方法,否则钩子就不会被 resolved。**
4242

File renamed without changes.
File renamed without changes.

Diff for: docs/zh/essentials/dynamic-matching.md renamed to docs/zh/guide/essentials/dynamic-matching.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const User = {
3535
| /user/:username | /user/evan | `{ username: 'evan' }` |
3636
| /user/:username/post/:post_id | /user/evan/post/123 | `{ username: 'evan', post_id: 123 }` |
3737

38-
除了 `$route.params` 外,`$route` 对象还提供了其它有用的信息,例如,`$route.query` (如果 URL 中有查询参数)、`$route.hash` 等等。你可以查看 [API 文档](../api/route-object.md) 的详细说明。
38+
除了 `$route.params` 外,`$route` 对象还提供了其它有用的信息,例如,`$route.query` (如果 URL 中有查询参数)、`$route.hash` 等等。你可以查看 [API 文档](../../api/route-object.md) 的详细说明。
3939

4040
## 响应路由参数的变化
4141

Diff for: docs/zh/essentials/getting-started.md renamed to docs/zh/guide/essentials/getting-started.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
::: tip 注意
44
教程中的案例代码将使用 [ES2015](https://github.com/lukehoban/es6features) 来编写。
5+
6+
同时,所有的例子都将使用完整版的 Vue 以解析模板。更多细节请[移步这里](https://cn.vuejs.org/v2/guide/installation.html#运行时-编译器-vs-只包含运行时)
57
:::
68

79
用 Vue.js + Vue Router 创建单页应用,是非常简单的。使用 Vue.js ,我们已经可以通过组合组件来组成应用程序,当你要把 Vue Router 添加进来,我们需要做的是,将组件 (components) 映射到路由 (routes),然后告诉 Vue Router 在哪里渲染它们。下面是个基本例子:
810

9-
::: tip 注意
10-
所有的例子都将使用完整版的 Vue 以解析模板。更多细节请[移步这里](https://cn.vuejs.org/v2/guide/installation.html#运行时-编译器-vs-只包含运行时)
11-
:::
12-
1311
## HTML
1412

1513
``` html
@@ -92,4 +90,4 @@ export default {
9290

9391
你可以看看这个[在线的](https://jsfiddle.net/yyx990803/xgrjzsup/)例子。
9492

95-
要注意,当 `<router-link>` 对应的路由匹配成功,将自动设置 class 属性值 `.router-link-active`。查看 [API 文档](../api/router-link.md) 学习更多相关内容。
93+
要注意,当 `<router-link>` 对应的路由匹配成功,将自动设置 class 属性值 `.router-link-active`。查看 [API 文档](../../api/router-link.md) 学习更多相关内容。
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)