Skip to content

Commit

Permalink
Prepare for cross-repo reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Apr 10, 2024
1 parent b05c3d0 commit aa429f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 5 additions & 4 deletions lib/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ 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}`);
pandoc(
{
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}`)
Expand All @@ -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,
});

Expand Down
2 changes: 0 additions & 2 deletions lib/pandoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit aa429f1

Please sign in to comment.