fix: Fix build script.
This commit is contained in:
parent
740c78f67c
commit
de5c60bd0a
|
|
@ -158,42 +158,33 @@ const cssPath = path.resolve(deployDir, 'css', 'index.css');
|
|||
function createTmpToHTML(fromPath, toPath, desJson, mdPath) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
let relative_path = '';
|
||||
const current_path = toPath.replace(new RegExp(`${deployDir}`), '');
|
||||
const tmpStr = await FS.readFile(fromPath);
|
||||
let mdPathName = '';
|
||||
let mdhtml = '';
|
||||
let relative_path = '';
|
||||
if (mdPath) {
|
||||
// CSS/JS 引用相对地址
|
||||
relative_path = '../';
|
||||
mdPathName = `/command/${desJson.n}.md`;
|
||||
const READMESTR = await FS.readFile(path.resolve(mdPath, `${desJson.n}.md`));
|
||||
mdhtml = await markdownToHTML(READMESTR.toString());
|
||||
}
|
||||
// 生成 HTML
|
||||
let html = ejs.render(tmpStr.toString(), {
|
||||
filename: fromPath,
|
||||
relative_path, // 当前文件相对于根目录的相对路径
|
||||
md_path: mdPathName || '', // markdown 路径
|
||||
mdhtml: mdhtml || '',
|
||||
current_path, // 当前 html 路径
|
||||
describe: desJson ? desJson : {}, // 当前 md 的描述
|
||||
}, { filename: fromPath });
|
||||
}, {
|
||||
filename: fromPath
|
||||
});
|
||||
|
||||
if (mdPath) {
|
||||
const READMESTR = await FS.readFile(path.resolve(mdPath, `${desJson.n}.md`));
|
||||
const mdhtml = await markdownToHTML(READMESTR.toString());
|
||||
html = html.replace(/{{content}}/, mdhtml);
|
||||
await FS.outputFile(toPath, html);
|
||||
console.log(` ${'♻️ →'.green} ${path.relative(process.cwd(), toPath)}`);
|
||||
// marked(READMESTR.toString(), (err, mdhtml) => {
|
||||
// if (err) return reject(err);
|
||||
// html = html.replace(/{{content}}/, mdhtml);
|
||||
// FS.outputFileSync(toPath, html);
|
||||
// console.log(` ${'→'.green} ${toPath.replace(process.cwd(), '')}`);
|
||||
// resolve(html);
|
||||
// });
|
||||
} else {
|
||||
await FS.outputFile(toPath, html);
|
||||
console.log(` ${'♻️ →'.green} ${path.relative(process.cwd(), toPath)}`);
|
||||
resolve(html);
|
||||
}
|
||||
await FS.outputFile(toPath, html);
|
||||
console.log(` ${'♻️ →'.green} ${path.relative(process.cwd(), toPath)}`);
|
||||
resolve();
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@
|
|||
<a target="_blank" href="https://github.com/jaywcjlove/linux-command/edit/master<%=md_path%>">添加实例</a>
|
||||
</span>
|
||||
<% } %>
|
||||
{{content}}
|
||||
|
||||
<%-mdhtml%>
|
||||
|
||||
</div>
|
||||
<%- include('widget/footer',{type: "list"}); %>
|
||||
<%- include('partial/footer'); %>
|
||||
Loading…
Reference in New Issue