docsify/packages/docsify-server-renderer/README.md

47 lines
929 B
Markdown
Raw Normal View History

2017-05-29 22:24:38 +08:00
# docsify-server-renderer
## Install
```bash
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',
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>
```