Skip to content

Commit 87678c8

Browse files
committed
Improve documentation
1 parent 23cab8b commit 87678c8

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

docs/route-transition.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Slick Router defines route transition as the process of changing from a route st
66

77
The transition object is itself a promise. It also contains the following attributes
88

9-
* `id`
10-
* `routes`
11-
* `path`
12-
* `pathname`
13-
* `params`
14-
* `query`
15-
* `prev`
9+
* `id`: the transition id
10+
* `routes`: the matched routes
11+
* `path`: the matched path
12+
* `pathname`: the matched path without query params
13+
* `params`: a hash with path params
14+
* `query`: a hash with the query
15+
* `prev`: the previous matched info
1616
* `routes`
1717
* `path`
1818
* `pathname`

docs/router-configuration.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const router = new Router(options)
2121

2222
## Routes Definition
2323

24-
The route tree con be configured as a callback, that receives a `route` function
24+
The route tree can be configured as a callback, that receives a `route` function
2525

26-
`route` first argument must be a unique name, the second (optional) argument is the route options and the third (also optional) is a caal back to configure the children.
26+
`route` first argument must be a unique name, the second (optional) argument is the route options and the third (also optional) is a callback to configure the children.
2727

2828
The route options can be `path`, `abstract` or arbitrary ones that can be used by the middlewares.
2929

@@ -80,33 +80,39 @@ const router = new Router()
8080
router.map(routes)
8181
```
8282

83-
### Nested paths
83+
### Nested Routes
8484

85-
Nested paths are concatenated unless they start with a '/'. For example
85+
Nested routes are defined by passing a callback to the `route` function or, when using the array notation, by defining a `children` property.
86+
87+
Each route is associated to a path composed by its own path concatenated with the parent routes paths.
8688

8789
```js
8890
router.map(function (route) {
8991
route('foo', {path: '/foo'}, function () {
90-
route('bar', {path: '/bar'}, function () {
91-
route('baz', {path: '/baz'})
92+
route('bar', {path: 'bar'}, function () {
93+
route('baz', {path: 'baz'})
9294
});
9395
})
9496
})
9597
```
9698

97-
The above map results in 1 URL `/baz` mapping to ['foo', 'bar', 'baz'] routes.
99+
The above map results in one path `/foo/bar/baz` mapping to ['foo', 'bar', 'baz'] routes.
100+
101+
Nested paths are concatenated unless they start with a '/'. For example
98102

99103
```js
100104
router.map(function (route) {
101105
route('foo', {path: '/foo'}, function () {
102-
route('bar', {path: 'bar'}, function () {
103-
route('baz', {path: 'baz'})
106+
route('bar', {path: '/bar'}, function () {
107+
route('baz', {path: '/baz'})
104108
});
105109
})
106110
})
107111
```
108112

109-
The above map results in 1 URL `/foo/bar/baz` mapping to ['foo', 'bar', 'baz'] routes.
113+
The above map results in one path `/baz` mapping to ['foo', 'bar', 'baz'] routes.
114+
115+
When a navigation occurs, the route with the path which best matches the current URL is matched together with its parents, e.g., when 'bar' route is matched, 'foo' will also be matched even if 'foo' path is not related at all with current URL.
110116

111117
### Dynamic paths
112118

0 commit comments

Comments
 (0)