Skip to content

Commit

Permalink
docs: unify config in quickstart (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse authored and fengmk2 committed Jun 23, 2017
1 parent c31bc15 commit 9099be9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ docs/**/contributing.md
docs/public
docs/plugins.png

package-lock.json
yarn.lock
!test/fixtures/apps/loader-plugin/node_modules
12 changes: 11 additions & 1 deletion docs/source/en/basics/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ module.exports = {
},
};
```

The configuration file can simplify to `exports.key = value` format

```js
exports.keys = 'my-cookie-secret-key';
exports.logger = {
level: 'DEBUG',
};
```

The configuration file can also return a function which could receive a parameter called `appInfo`

```js
Expand Down Expand Up @@ -75,7 +85,7 @@ Here is one sequence of loading configurations under "prod" environment, in whic
-> plugin config.prod.js
-> framework config.prod.js
-> application config.prod.js

**Note: there will be plugin loading sequence, but the approximate order is similar. For specific logic, please check the [loader](../advanced/loader.md) .**

### Merging rule
Expand Down
27 changes: 11 additions & 16 deletions docs/source/en/intro/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ module.exports = app => {
};
```

Then add a configuration file:
Then add a [configuration](../basics/config.md) file:

```js
// config/config.default.js
// should change to your own keys
exports.keys = <YOUR_SECURITY_COOKE_KEYS>;
```

Expand Down Expand Up @@ -174,18 +173,13 @@ exports.nunjucks = {

```js
// config/config.default.js
module.exports = appInfo => {
const config = {};
config.keys = <YOUR_SECURITY_COOKE_KEYS>;

// add config
config.view = {
defaultViewEngine: 'nunjucks',
mapping: {
'.tpl': 'nunjucks',
},
}
return config;
exports.keys = <YOUR_SECURITY_COOKE_KEYS>;
// add view's configurations
exports.view = {
defaultViewEngine: 'nunjucks',
mapping: {
'.tpl': 'nunjucks',
},
};
```

Expand Down Expand Up @@ -308,6 +302,7 @@ And also add config.

```js
// config/config.default.js
// add news' configurations
exports.news = {
pageSize: 5,
serverUrl: 'https://hacker-news.firebaseio.com/v0',
Expand Down Expand Up @@ -367,11 +362,11 @@ module.exports = (options, app) => {
};

// config/config.default.js
// mount middleware
// add middleware robot
exports.middleware = [
'robot'
];
// middleware config
// robot's configurations
exports.robot = {
ua: [
/Baiduspider/i,
Expand Down
9 changes: 9 additions & 0 deletions docs/source/zh-cn/basics/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ module.exports = {
};
```

配置文件也可以简化的写成 `exports.key = value` 形式

```js
exports.keys = 'my-cookie-secret-key';
exports.logger = {
level: 'DEBUG',
};
```

配置文件也可以返回一个 function,可以接受 appInfo 参数

```js
Expand Down
27 changes: 11 additions & 16 deletions docs/source/zh-cn/intro/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ module.exports = app => {
};
```

加一个配置文件
加一个[配置文件](../basics/config.md)

```js
// config/config.default.js
// 切记:要改为自己的 key 值
exports.keys = <此处改为你自己的 Cookie 安全字符串>;
```

Expand Down Expand Up @@ -162,18 +161,13 @@ exports.nunjucks = {

```js
// config/config.default.js
module.exports = appInfo => {
const config = {};
config.keys = <此处改为你自己的 Cookie 安全字符串>;

// 添加配置
config.view = {
defaultViewEngine: 'nunjucks',
mapping: {
'.tpl': 'nunjucks',
},
}
return config;
exports.keys = <此处改为你自己的 Cookie 安全字符串>;
// 添加 view 配置
exports.view = {
defaultViewEngine: 'nunjucks',
mapping: {
'.tpl': 'nunjucks',
},
};
```

Expand Down Expand Up @@ -289,6 +283,7 @@ module.exports = app => {

```js
// config/config.default.js
// 添加 news 的配置项
exports.news = {
pageSize: 5,
serverUrl: 'https://hacker-news.firebaseio.com/v0',
Expand Down Expand Up @@ -341,11 +336,11 @@ module.exports = (options, app) => {
};

// config/config.default.js
// mount middleware
// add middleware robot
exports.middleware = [
'robot'
];
// middleware config
// robot's configurations
exports.robot = {
ua: [
/Baiduspider/i,
Expand Down

0 comments on commit 9099be9

Please sign in to comment.