Port cli.js to TypeScript
This commit is contained in:
parent
8fb809fa95
commit
fed46dbb4a
3 changed files with 3 additions and 2 deletions
23
cli.ts
Normal file
23
cli.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { pages } from "./content/pages.js"
|
||||
import { prettify, htmlDocument } from "antihtml";
|
||||
import * as fs from "node:fs"
|
||||
|
||||
const outDir = "build/web";
|
||||
if (!fs.existsSync(outDir)) {
|
||||
fs.mkdirSync(outDir);
|
||||
}
|
||||
|
||||
for (const page of pages) {
|
||||
const dirSep = page.ref.indexOf("/");
|
||||
if (dirSep !== -1) {
|
||||
const dir = `${outDir}/${page.ref.slice(0, dirSep)}`;
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir);
|
||||
}
|
||||
}
|
||||
console.log(`writing ${outDir}/${page.ref}`);
|
||||
fs.writeFileSync(`${outDir}/${page.ref}`, htmlDocument(prettify(page.content)));
|
||||
}
|
||||
|
||||
console.log(`writing ${outDir}/style.css`);
|
||||
fs.writeFileSync(`${outDir}/style.css`, fs.readFileSync("public/style.css"));
|
Loading…
Add table
Add a link
Reference in a new issue