-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
1 parent
3444884
commit eba1c98
Showing
6 changed files
with
68 additions
and
12 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,12 +1,46 @@ | ||
var serveStatic = require('serve-static') | ||
var http = require('http') | ||
var fs = require('fs') | ||
var Renderer = require('./packages/docsify-server-renderer/build.js') | ||
|
||
var renderer = new Renderer({ | ||
template: ` | ||
<!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="/themes/vue.css" title="vue"> | ||
</head> | ||
<body> | ||
<!--inject-app--> | ||
<!--inject-config--> | ||
<script src="/lib/docsify.js"></script> | ||
</body> | ||
</html>`, | ||
config: { | ||
name: 'docsify', | ||
repo: 'qingwei-li/docsify', | ||
basePath: '/docs/', | ||
loadNavbar: true, | ||
loadSidebar: true, | ||
subMaxLevel: 3, | ||
auto2top: true | ||
}, | ||
path: './' | ||
}) | ||
|
||
http.createServer(function (req, res) { | ||
serveStatic('.')(req, res, function () { | ||
res.writeHead(200, { 'Content-Type': 'text/html' }) | ||
// TEST SSR | ||
// const html = renderer.renderToString(req.url) | ||
// res.end(html) | ||
|
||
res.writeHead(404, { 'Content-Type': 'text/html' }) | ||
res.end(fs.readFileSync('dev.html')) | ||
}) | ||
}).listen(3000, '0.0.0.0') | ||
|
||
console.log(`\nListening at http://0.0.0.0:3000\n`) | ||
|
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
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
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
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
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