all repos — kushiyaki @ 5e18b49804cd755b996f3d459b677ac823d40cf4

🍢 A tiny static site generator for grilling markdown files to perfection

looper.js (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
import { emptyDir, writeFile } from "fs-extra";
import cpy from "cpy";
import { glob } from "glob";
import { writePage } from "./writePage";

//mise en place
emptyDir("out", { recursive: true }); // clears the output folder
await cpy(["input/**", "!input/**/*{.md,.jsx}"], "out", { flat: true }); //copies all the assets into out/

for (const file of await glob("input/**/*.md", { nodir: true })) {
  await writeFile(
    file.replace(/input[\/\w]*\//, "out/").replace(".md", ".html"),
    await writePage(file),
  );
}