You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
keys/prepare.js

24 lines
837 B
JavaScript

let fs = require("fs");
let path = require("path");
const staticDir = path.join(__dirname, "static");
module.exports = (app) => {
function renderAndSave(file, template, options) {
file = path.join(staticDir, file);
app.render(template, options, (e, r) => {
if (e) return fs.writeFile(file, "<!DOCTYPE html><html><head><title>Something went wrong!</title></head><body><h1>Something went wrong!</h1><p>Could not render this page! Please contact the administrator!</p></body></html>");
return fs.writeFile(file, r);
});
}
if (!fs.existsSync(staticDir)) fs.mkdirSync(staticDir);
[
["index.htm", "linkList", {
links: [
{href: "/ssh", name: "All SSH Keys"},
]
}],
].forEach(e => renderAndSave(e[0], e[1], e[2]));
};