forked from vuejs/vuepress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
139 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,99 @@ | ||
# Node.js API | ||
# Node.js API <Badge text="1.0.0-alpha.44+"/> | ||
|
||
## Usage | ||
|
||
```js | ||
const vuepress = require('vuepress') | ||
const { createApp, dev, build, eject } = require('vuepress') | ||
``` | ||
|
||
## Global Methods | ||
## Methods | ||
|
||
### createApp(\[options]): Promise\<App> | ||
|
||
Create a VuePress application. | ||
|
||
#### App.prototype.process: () => Promise\<void> | never | ||
|
||
A asynchronous method used to prepare the context of the current app. which contains loading pages and plugins, apply plugins, etc. | ||
|
||
### vuepress.dev | ||
#### App.prototype.dev: () => Promise\<App> | never | ||
|
||
Start a development server. | ||
Launch a dev process with current app context. | ||
|
||
### vuepress.build | ||
#### App.prototype.build: () => Promise\<App> | never | ||
|
||
Build dir as a static site. | ||
Launch a build process with current app context. | ||
|
||
### vuepress.eject | ||
|
||
Copy the default theme into `.vuepress/theme` for customization. | ||
### dev(\[options]): Promise\<App> | ||
|
||
Start a development server, actually it's implemented by `createApp`: | ||
|
||
```js | ||
async function dev (options) { | ||
const app = createApp(options) | ||
await app.process() | ||
return app.dev() | ||
} | ||
``` | ||
|
||
### vuepress.createApp | ||
### build(\[options]): Promise\<App> | ||
|
||
Create a VuePress App for for customization. For example, | ||
Build your source files as a static site, actually it's implemented by `createApp`: | ||
|
||
```js | ||
const app = vuepress.createApp(/* options */) | ||
app.process().then(() => { | ||
console.log('ready!') | ||
app.dev() | ||
}) | ||
async function build (options) { | ||
const app = createApp(options) | ||
await app.process() | ||
return app.build() | ||
} | ||
``` | ||
|
||
## App Options | ||
### eject(targetDir): Promise\<void> | ||
|
||
### options.sourceDir | ||
Copy the default theme into `{targetDir}/.vuepress/theme` for customization. | ||
|
||
Specify the source directory for VuePress. | ||
|
||
### options.theme | ||
## Options | ||
|
||
### sourceDir | ||
|
||
- Type: `string` | ||
- Required: `true` | ||
|
||
Specify the source directory of your VuePress site. | ||
|
||
### theme | ||
|
||
- Type: `string` | ||
- Required: `false` | ||
|
||
See [theme](../config/README.md#theme). | ||
|
||
### options.plugins | ||
### plugins | ||
|
||
- Type: `array` | ||
- Required: `false` | ||
|
||
See [plugins](../config/README.md#plugins). | ||
|
||
### options.temp | ||
### temp | ||
|
||
- Type: `string` | ||
- Required: `false` | ||
|
||
See [temp](../config/README.md#temp). | ||
|
||
### options.dest | ||
### dest | ||
|
||
- Type: `string` | ||
- Required: `false` | ||
|
||
See [dest](../config/README.md#dest). | ||
|
||
### options.siteConfig | ||
### siteConfig | ||
|
||
- Type: `object` | ||
- Required: `{}` | ||
|
||
See [siteConfig](../config/README.md). | ||
It's very useful when you're writing tests and don't want to depend on actual config file, for all options please head [siteConfig](../config/README.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,100 @@ | ||
# Node.js API | ||
# Node.js API <Badge text="1.0.0-alpha.44+"/> | ||
|
||
## 使用 | ||
|
||
```js | ||
const vuepress = require('vuepress') | ||
const { createApp, dev, build, eject } = require('vuepress') | ||
``` | ||
|
||
## 全局方法 | ||
## 方法 | ||
|
||
### createApp(\[options]): Promise\<App> | ||
|
||
创建一个 VuePress 应用实例。 | ||
|
||
#### App.prototype.process: () => Promise\<void> | never | ||
|
||
用于准备当前站点上下文的异步方法。其中包含加载页面和插件、应用插件等。 | ||
|
||
### vuepress.dev | ||
#### App.prototype.dev: () => Promise\<App> | never | ||
|
||
启动一个开发服务器。 | ||
使用当前应用程序上下文启动一个 devProcess. | ||
|
||
### vuepress.build | ||
|
||
生成一个静态站点。 | ||
#### App.prototype.build: () => Promise\<App> | never | ||
|
||
### vuepress.eject | ||
使用当前应用程序上下文启动一个 buildProcess. | ||
|
||
将默认主题复制到 `.vuepress/theme` 目录,以供自定义。 | ||
### dev(\[options]): Promise\<App> | ||
|
||
### vuepress.createApp | ||
启动一个 Dev Server,实际上它是由 `createapp` 实现的: | ||
|
||
创建一个 VuePress 应用。 | ||
```js | ||
async function dev (options) { | ||
const app = createApp(options) | ||
await app.process() | ||
return app.dev() | ||
} | ||
``` | ||
|
||
### build(\[options]): Promise\<App> | ||
|
||
将源文件构建为静态站点, 实际上它是由 `createapp` 实现的: | ||
|
||
```js | ||
const app = vuepress.createApp(/* options */) | ||
app.process().then(() => { | ||
console.log('ready!') | ||
app.dev() | ||
}) | ||
async function build (options) { | ||
const app = createApp(options) | ||
await app.process() | ||
return app.build() | ||
} | ||
``` | ||
|
||
## App 选项 | ||
### eject(targetDir): Promise\<void> | ||
|
||
将默认主题复制到 `{targetDir}/.vuepress/theme`中进行自定义。 | ||
|
||
|
||
## Options | ||
|
||
### sourceDir | ||
|
||
- 类型: `string` | ||
- 默认值: `true` | ||
|
||
指定 VuePress 站点的源目录。 | ||
|
||
### theme | ||
|
||
- 类型: `string` | ||
- 默认值: `false` | ||
|
||
参见 [theme](../config/README.md#theme)。 | ||
|
||
### plugins | ||
|
||
### options.sourceDir | ||
- 类型: `array` | ||
- 默认值: `false` | ||
|
||
指定 VuePress 的根目录。 | ||
参见 [plugins](../config/README.md#plugins)。 | ||
|
||
### options.theme | ||
### temp | ||
|
||
查看 [theme](../config/README.md#theme)。 | ||
- 类型: `string` | ||
- 默认值: `false` | ||
|
||
### options.plugins | ||
参见 [temp](../config/README.md#temp)。 | ||
|
||
查看 [plugins](../config/README.md#plugins)。 | ||
### dest | ||
|
||
### options.temp | ||
- 类型: `string` | ||
- 默认值: `false` | ||
|
||
查看 [temp](../config/README.md#temp)。 | ||
参见 [dest](../config/README.md#dest)。 | ||
|
||
### options.dest | ||
### siteConfig | ||
|
||
查看 [dest](../config/README.md#dest)。 | ||
- 类型: `object` | ||
- 默认值: `{}` | ||
|
||
### options.siteConfig | ||
当你想编写测试且不想依赖于实际的配置文件时,它将非常有用。想要查看所有的配置选项,请移步 [siteConfig](../config/README.md)。 | ||
|
||
查看 [siteConfig](../config/README.md)。 |