2017-05-29 22:24:38 +08:00
|
|
|
# docsify-server-renderer
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
```bash
|
2017-08-18 09:06:34 +08:00
|
|
|
yarn add docsify-server-renderer
|
2017-05-29 22:24:38 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
|
|
|
var Renderer = require('docsify-server-renderer')
|
|
|
|
var readFileSync = require('fs').readFileSync
|
|
|
|
|
|
|
|
// init
|
|
|
|
var renderer = new Renderer({
|
2017-05-30 04:27:49 +08:00
|
|
|
template: readFileSync('./docs/index.template.html', 'utf-8').,
|
2017-05-29 22:24:38 +08:00
|
|
|
config: {
|
|
|
|
name: 'docsify',
|
2018-07-01 13:48:44 +08:00
|
|
|
repo: 'docsifyjs/docsify'
|
2017-05-29 22:24:38 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-05-30 11:54:37 +08:00
|
|
|
renderer.renderToString(url)
|
2017-05-29 22:24:38 +08:00
|
|
|
.then(html => {})
|
|
|
|
.catch(err => {})
|
|
|
|
```
|
|
|
|
|
|
|
|
*index.template.html*
|
|
|
|
|
|
|
|
```html
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>docsify</title>
|
|
|
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
|
|
<link rel="stylesheet" href="//unpkg.com/docsify/themes/buble.css" title="buble" disabled>
|
|
|
|
</head>
|
|
|
|
<body>
|
2017-05-30 00:23:43 +08:00
|
|
|
<!--inject-app-->
|
|
|
|
<!--inject-config-->
|
2017-05-29 22:24:38 +08:00
|
|
|
<script src="//unpkg.com/docsify/lib/docsify.js"></script>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
```
|