diff --git a/lib/pages.js b/lib/pages.js index 5f371233..ef43d9f4 100644 --- a/lib/pages.js +++ b/lib/pages.js @@ -2,7 +2,7 @@ const pandoc = require("./pandoc"); const fs = require("fs"); const VOCAB = require("../package.json").name; -const REPO = process.argv[2]; +const REPO = process.argv[process.argv.length - 1]; function file(dir, title, filename) { console.log(`${dir}/${filename}`); @@ -10,20 +10,21 @@ function file(dir, title, filename) { { stdin: fs.createReadStream(`${__dirname}/../${dir}/${filename}`), stdout: fs.createWriteStream( - `${__dirname}/../_site/${dir}/${filename === "README.md" ? "index.html" : filename.replace(/\.md$/, ".html")}`, + `_site/${dir}/${filename === "README.md" ? "index.html" : filename.replace(/\.md$/, ".html")}`, ), }, { "-c": `/${VOCAB}/styles/style.css`, "-F": `${__dirname}/md2html.js`, "-M": `title=${REPO}${title ? " - " + title : ""}`, + "--template": "assets/template", }, ); } function directory(dir, title) { if (fs.existsSync(`${__dirname}/../${dir}`)) { - fs.cpSync(`${__dirname}/../${dir}`, `${__dirname}/../_site/${dir}`, { + fs.cpSync(`${__dirname}/../${dir}`, `_site/${dir}`, { recursive: true, }); fs.readdirSync(`${__dirname}/../${dir}`) @@ -34,7 +35,7 @@ function directory(dir, title) { } } -fs.cpSync(`${__dirname}/../assets/styles`, `${__dirname}/../_site/styles`, { +fs.cpSync(`${__dirname}/../assets/styles`, `_site/styles`, { recursive: true, }); diff --git a/lib/pandoc.js b/lib/pandoc.js index 0f02ba3f..bfc6a773 100644 --- a/lib/pandoc.js +++ b/lib/pandoc.js @@ -30,8 +30,6 @@ function pandoc({ stdin, stdout }, options = {}) { else if (value && param.startsWith("-")) opts.push(param, value); else opts.push(param); }); - if (!options["--template"]) - opts.push(`--template=${__dirname}/../assets/template`); var proc = spawn("pandoc", opts); proc.stderr.on("data", function (err) { console.error(err.toString());