Skip to content

Commit ce3a7bf

Browse files
committed
📔 refactor: docs
- Update examples - Add new `async` hooks usage examples - Lint with markdownlint
1 parent 27ae89c commit ce3a7bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+378
-208
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ FlowRouter.route('/', {
4848
name: 'index',
4949
action() {
5050
// Render a template using Blaze
51-
this.render('templateName');
51+
this.render('layoutName', 'index');
5252

5353
// Can be used with BlazeLayout,
5454
// and ReactLayout for React-based apps
55+
},
56+
waitOn() {
57+
// Dynamically load JS per route
58+
return [import('/imports/client/index.js')];
5559
}
5660
});
5761

@@ -67,11 +71,12 @@ FlowRouter.route('*', {
6771
});
6872
```
6973

70-
> NOTE: If you're using TypeScript, FlowRouter supports it. For types to work you need to install and follow the instructions of [zodern:meteor-types](https://github.com/zodern/meteor-types#meteor-apps) if you haven't done it already.
74+
> [!TIP]
75+
> If you're using TypeScript, FlowRouter supports it. For types to work you need to install and follow the instructions of [`zodern:meteor-types`](https://github.com/zodern/meteor-types#meteor-apps)
7176
7277
## Documentation
7378

74-
- Continue with our [wiki](https://github.com/veliovgroup/flow-router/wiki);
79+
- Continue with our [wiki](https://github.com/veliovgroup/flow-router/wiki) or [README index](https://github.com/veliovgroup/flow-router/blob/master/docs/README.md);
7580
- [Quick start](https://github.com/veliovgroup/flow-router/blob/master/docs/quick-start.md) tutorial;
7681
- All docs as [single document](https://github.com/veliovgroup/flow-router/blob/master/docs/full.md).
7782

@@ -110,7 +115,7 @@ MONGO_URL="mongodb://127.0.0.1:27017/flow-router-tests" meteor test-packages ./
110115

111116
### Running Typescript Test
112117

113-
1. Install [tsd](https://github.com/SamVerschueren/tsd) as a global package;
118+
1. Install [`tsd`](https://github.com/SamVerschueren/tsd) as a global package;
114119
2. Run `tsd` in your terminal. `tsd` will find the correct `*.test.d.ts` file and return with any errors.
115120

116121
## Support this project:

docs/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ FlowRouter.route('*', {
3636
});
3737
```
3838

39-
For the new apps it is recommended to set `decodeQueryParamsOnce` to `true`. This flag is here to fix [#78](https://github.com/veliovgroup/flow-router/issues/78). By default it is `false` due to its historical origin for compatibility purposes.
39+
> [!IMPORTANT]
40+
> For the new apps it is recommended to set `decodeQueryParamsOnce` to `true`. This flag is here to fix [#78](https://github.com/veliovgroup/flow-router/issues/78). By default it is `false` due to its historical origin for compatibility purposes
4041
4142
## General tutorials:
4243

@@ -46,6 +47,7 @@ For the new apps it is recommended to set `decodeQueryParamsOnce` to `true`. Thi
4647
- [Templating with Data](https://github.com/veliovgroup/flow-router/blob/master/docs/templating-with-data.md)
4748
- [Auto-scroll](https://github.com/veliovgroup/flow-router/blob/master/docs/auto-scroll.md)
4849
- [React.js usage](https://github.com/veliovgroup/flow-router/blob/master/docs/react.md)
50+
- [Usage in real application](https://github.com/veliovgroup/meteor-files-website/tree/master/imports/client/router)
4951

5052
## Hooks (*in execution order*):
5153

@@ -123,6 +125,9 @@ For the new apps it is recommended to set `decodeQueryParamsOnce` to `true`. Thi
123125

124126
## Support this project:
125127

126-
This project wouldn't be possible without [ostr.io](https://ostr.io).
127-
128-
Using [ostr.io](https://ostr.io) you are not only [protecting domain names](https://ostr.io/info/domain-names-protection), [monitoring websites and servers](https://ostr.io/info/monitoring), using [Prerendering for better SEO](https://ostr.io/info/prerendering) of your JavaScript website, but support our Open Source activity, and great packages like this one could be available for free.
128+
- Upload and share files using [☄️ meteor-files.com](https://meteor-files.com/?ref=github-flowrouter-repo-footer) — Continue interrupted file uploads without losing any progress. There is nothing that will stop Meteor from delivering your file to the desired destination
129+
- Use [▲ ostr.io](https://ostr.io?ref=github-flowrouter-repo-footer) for [Server Monitoring](https://snmp-monitoring.com), [Web Analytics](https://ostr.io/info/web-analytics?ref=github-flowrouter-repo-footer), [WebSec](https://domain-protection.info), [Web-CRON](https://web-cron.info) and [SEO Pre-rendering](https://prerendering.com) of a website
130+
- Star on [GitHub](https://github.com/veliovgroup/flow-router)
131+
- Star on [Atmosphere](https://atmospherejs.com/ostrio/flow-router-extra)
132+
- [Sponsor via GitHub](https://github.com/sponsors/dr-dimitru)
133+
- [Support via PayPal](https://paypal.me/veliovgroup)

docs/api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# API:
1+
# API
22

33
- __General Methods:__
44
- [`.go()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/go.md)

docs/api/current.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
```js
44
FlowRouter.current();
55
```
6-
- Returns {*Object*}
6+
7+
- Returns {*Object*}
78

89
Get the current state of the router. **This API is not reactive**.
910
If you need to watch the changes in the path simply use `FlowRouter.watchPathChange()`.
1011

1112
#### Example
13+
1214
```js
1315
// route def: /apps/:appId
1416
// url: /apps/this-is-my-app?show=yes&color=red
@@ -26,4 +28,5 @@ console.log(current);
2628
```
2729

2830
#### Further reading
29-
- [`.watchPathChange()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/watchPathChange.md)
31+
32+
- [`.watchPathChange()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/watchPathChange.md)

docs/api/decodeQueryParamsOnce.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ FlowRouter.decodeQueryParamsOnce = true;
1212
#### Example
1313

1414
Given the URL in the address bar:
15-
```
15+
16+
```plain
1617
http://localhost:3000/signin?after=%2Foauth%2Fauthorize%3Fclient_id%3D123%26redirect_uri%3Dhttps%253A%252F%252Fothersite.com%252F
1718
```
1819

1920
If `decodeQueryParamsOnce` is not set or set to `false` ❌ ...
21+
2022
```js
2123
FlowRouter.getQueryParam("after");
2224
// returns: "/oauth/authorize?client_id=123"
@@ -26,6 +28,7 @@ FlowRouter.current().queryParams;
2628
```
2729

2830
If `decodeQueryParamsOnce` is set to `true` ✔️ ...
31+
2932
```js
3033
FlowRouter.getQueryParam("after");
3134
// returns: "/oauth/authorize?client_id=123&redirect_uri=https%3A%2F%2Fothersite.com%2F"
@@ -37,5 +40,6 @@ FlowRouter.current().queryParams;
3740
The former is no longer recommended, but to maintain compatibility with legacy apps, `false` is the default value for this flag. Enabling this flag manually with `true` is recommended for all new apps. For more info, see [#78](https://github.com/veliovgroup/flow-router/issues/78).
3841

3942
#### Further reading
40-
- [`.getQueryParam()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/getQueryParam.md)
41-
- [`.current()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/current.md)
43+
44+
- [`.getQueryParam()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/getQueryParam.md)
45+
- [`.current()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/current.md)

docs/api/getParam.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
```js
44
FlowRouter.getParam(paramName);
55
```
6-
- `paramName` {*String*}
7-
- Returns {*String*}
6+
7+
- `paramName` {*String*}
8+
- Returns {*String*}
89

910
Reactive function which you can use to get a parameter from the URL.
1011

1112
#### Example
13+
1214
```js
1315
// route def: /apps/:appId
1416
// url: /apps/this-is-my-app

docs/api/getQueryParam.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
```js
44
FlowRouter.getQueryParam(queryKey);
55
```
6-
- `queryKey` {*String*}
7-
- Returns {*String*}
6+
7+
- `queryKey` {*String*}
8+
- Returns {*String*}
89

910
Reactive function which you can use to get a value from the query string.
1011

docs/api/getRouteName.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
```js
44
FlowRouter.getRouteName();
55
```
6-
- Returns {*String*}
6+
7+
- Returns {*String*}
78

89
Use to get the name of the route reactively.
910

1011
#### Example
12+
1113
```js
1214
Tracker.autorun(function () {
1315
const routeName = FlowRouter.getRouteName();
@@ -16,4 +18,5 @@ Tracker.autorun(function () {
1618
```
1719

1820
#### Further reading
19-
- [`.current()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/current.md)
21+
22+
- [`.current()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/current.md)

docs/api/go.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
### go method
22

33
`.go(path, params, qs)`
4-
- `path` {*String*} - Path or Route's name
5-
- `params` {*Object*} - Serialized route parameters, `{ _id: 'str' }`
6-
- `qs` {*Object*} - Serialized query string, `{ key: 'val' }`
7-
- Returns {*true*}
4+
5+
- `path` {*String*} - Path or Route's name
6+
- `params` {*Object*} - Serialized route parameters, `{ _id: 'str' }`
7+
- `qs` {*Object*} - Serialized GET-query string, `{ key: 'val' }`
8+
- Returns {*true*}
89

910
```js
1011
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
@@ -19,5 +20,6 @@ FlowRouter.go('blogPost', { _id: 'post_id' }, { commentId: '123' }); // /blog/po
1920
```
2021

2122
#### Further reading
22-
- [`.route()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/route.md)
23-
- [`.getRouteName()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/getRouteName.md)
23+
24+
- [`.route()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/route.md)
25+
- [`.getRouteName()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/getRouteName.md)

docs/api/group.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
Use group routes for better route organization.
44

55
`.group(options)`
6-
- `options` {*Object*} - [Optional]
7-
- `options.name` {*String*} - [Optional] Route's name
8-
- `options.prefix` {*String*} - [Optional] Route prefix
9-
- `options[prop-name]` {*Any*} - [Optional] Any property which will be available inside route call
10-
- `options[hook-name]` {*Function*} - [Optional] See [all available hooks](https://github.com/veliovgroup/flow-router/tree/master/docs#hooks-in-execution-order)
11-
- Returns {*Group*}
6+
7+
- `options` {*Object*} - [Optional]
8+
- `options.name` {*String*} - [Optional] Route's name
9+
- `options.prefix` {*String*} - [Optional] Route prefix
10+
- `options[prop-name]` {*Any*} - [Optional] Any property which will be available inside route call
11+
- `options[hook-name]` {*Function*} - [Optional] See [all available hooks](https://github.com/veliovgroup/flow-router/tree/master/docs#hooks-in-execution-order)
12+
- Returns {*Group*}
1213

1314
```js
1415
const adminRoutes = FlowRouter.group({
@@ -33,6 +34,7 @@ adminRoutes.route('/posts', {
3334
```
3435

3536
#### Nested Group
37+
3638
```js
3739
const adminRoutes = FlowRouter.group({
3840
prefix: '/admin',
@@ -51,17 +53,20 @@ superAdminRoutes.route('/post', {
5153
```
5254

5355
#### Get group name
56+
5457
```js
5558
FlowRouter.current().route.group.name
5659
```
5760

5861
This can be useful for determining if the current route is in a specific group (e.g. *admin*, *public*, *loggedIn*) without needing to use prefixes if you don't want to. If it's a nested group, you can get the parent group's name with:
62+
5963
```js
6064
FlowRouter.current().route.group.parent.name
6165
```
6266

6367
#### Further reading
64-
- [`.triggersEnter()` hooks](https://github.com/veliovgroup/flow-router/blob/master/docs/hooks/triggersEnter.md)
65-
- [`.action()` hook](https://github.com/veliovgroup/flow-router/blob/master/docs/hooks/action.md)
66-
- [`.route()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/route.md)
67-
- [`.current()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/current.md)
68+
69+
- [`.triggersEnter()` hooks](https://github.com/veliovgroup/flow-router/blob/master/docs/hooks/triggersEnter.md)
70+
- [`.action()` hook](https://github.com/veliovgroup/flow-router/blob/master/docs/hooks/action.md)
71+
- [`.route()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/route.md)
72+
- [`.current()` method](https://github.com/veliovgroup/flow-router/blob/master/docs/api/current.md)

0 commit comments

Comments
 (0)