1 Star 0 Fork 1

YC小怪/docs-rancher2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
pdf-generate.js 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
orangedeng 提交于 2021-03-11 11:59 . Fix generate pdf drone step
#!/usr/bin/env node
const chalk = require("chalk");
const fs = require("fs");
var pdf = require("docusaurus-pdf/lib");
const docs_dir = process.env.DOCS_OUTPUT || "build_docs/RancherCNDocsPDF";
var docs = {
harverster: {
filename: "Harvester.pdf",
},
k3s: {
filename: "K3s.pdf",
},
octopus: {
index: "/about/_index/",
filename: "Octopus_CN_Doc.pdf",
},
rancher1: {
filename: "rancher1.6.pdf",
},
rancher2: {
filename: "Rancher2.x_CN_Doc.pdf",
},
rke: {
filename: "rke.pdf",
},
};
fs.mkdirSync(docs_dir, (options = { recursive: true }));
var pdfCacheId = "";
Object.keys(require.cache).forEach((k) => {
if (k.includes("docusaurus-pdf/lib")) {
pdfCacheId = k;
}
});
var p = Promise.resolve();
fs.readdirSync("docs").forEach((dirname) => {
var config = docs[dirname] || {};
var index = config["index"] || "/_index/";
var url = "/docs/" + dirname + index;
var filename = config["filename"] || dirname + ".pdf";
filename = docs_dir + "/" + filename;
p = p
.then(async () => {
try {
delete require.cache[pdfCacheId];
pdf = require("docusaurus-pdf/lib");
const res = await pdf.generatePdfFromBuildSources(
"./build/",
url,
"",
filename,
["--no-sandbox"]
);
console.log("pdf generated for", filename);
} catch (err) {
throw err;
}
})
.catch((err) => {
console.log(
chalk.red("failed to generate pdf", filename, ",", err)
);
process.exit(1);
});
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yc_little_monster/docs-rancher2.git
git@gitee.com:yc_little_monster/docs-rancher2.git
yc_little_monster
docs-rancher2
docs-rancher2
master

搜索帮助