Skip to content

Commit ef77394

Browse files
committed
fix: copy md file
1 parent 5d168b5 commit ef77394

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed

lib/commands/static.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const fg = require("fast-glob");
99
const write = require("write");
1010
const ora = require("ora");
1111
const chalk = require("chalk");
12+
const fs = require("fs");
1213
const resolve = util.resolve;
1314

1415
module.exports = function(
@@ -19,6 +20,9 @@ module.exports = function(
1920
) {
2021
path = resolve(path || ".");
2122
const config = util.getConfig(configFile);
23+
// docs absolute path
24+
config.path = path;
25+
2226
const server = connect();
2327
const indexFile = resolve(path, indexName || "index.html");
2428
const render = new Renderer(config);
@@ -31,21 +35,28 @@ module.exports = function(
3135
spinner.start("Rendering");
3236

3337
getPort()
34-
.then(port => {
38+
.then(async port => {
3539
server.use(serveStatic(path, { index: indexFile }));
3640
app = server.listen(port);
3741

38-
return Promise.all(files.map(file => render.render(file)));
42+
const queue = [];
43+
for (const file of files) {
44+
const res = await render.render(file);
45+
queue.push(res);
46+
spinner.text = "Rendering " + file;
47+
}
48+
return queue;
3949
})
4050
.then(data => {
4151
// 保存文件
4252
return Promise.all(
43-
data.map(({ url, content }) => {
53+
data.map(({ url, content, path }) => {
4454
const filePath = url
4555
.replace(/README\.md$/, "index.html")
4656
.replace(/\.md$/, ".html");
4757
spinner.text = `Rendering ${url}`;
4858
write(resolve(util.cwd(), dest, filePath), content);
59+
fs.copyFileSync(path, resolve(util.cwd(), dest, url));
4960
})
5061
);
5162
})

package-lock.json

Lines changed: 11 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)