docsify/packages/docsify-server-renderer
Joe Pea 60ccf09086 initial SSR working independently without a seconds server
Many things work. What doesn't work (needs work):

- Any dynamic config options (f.e. any that use functions) need to be specified in the HTML by augmenting the injected config object. This includes plugins, Vue components, and similar.
- Plugins and Vue don't work on initial SSR render. Switch pages dynamically and they work during the dynamic markdown handling.
- Cover page causes an error
- Search plugin causes an error
2021-05-17 23:40:00 -07:00
..
2017-05-30 04:28:30 +08:00
2020-11-01 23:45:36 -08:00

docsify-server-renderer

Install

yarn add docsify-server-renderer

Usage

import Renderer from 'docsify-server-renderer'
import {readFileSync} from 'fs'

// init
var renderer = new Renderer({
  template: readFileSync('./docs/index.template.html', 'utf-8'),
  config: {
    name: 'docsify',
    repo: 'docsifyjs/docsify'
  }
})

renderer.renderToString(url)
  .then(html => {})
  .catch(err => {})

index.template.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>docsify</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css" title="vue">
</head>
<body>
  <!--inject-app-->
  <!--inject-config-->
  <script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.js"></script>
</body>
</html>