all repos — kushiyaki @ d17890b7045c4b8bed81b5fcff23149d0d75f408

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

feat: make folders respect cwd as installed module
trickyni trickyniv56@gmail.com
Sun, 24 May 2026 09:53:40 +0300
commit

d17890b7045c4b8bed81b5fcff23149d0d75f408

parent

b3e7964380d1c3213fbc9df3a67ef5d21f990388

5 files changed, 32 insertions(+), 13 deletions(-)

jump to
M .gitignore.gitignore

@@ -1,5 +1,5 @@

+addons input out +templates node_modules -addons -package.json.bak
M createSiteIndex.jscreateSiteIndex.js

@@ -1,9 +1,11 @@

import { glob } from "glob"; +import { resolve } from "path"; import { read } from "to-vfile"; import { matter } from "vfile-matter"; export async function createSiteIndex() { - let site = await glob("input/**/*.md", { nodir: true }); + const inputDir = resolve(process.cwd(), "input"); + let site = await glob(`${inputDir}/**/*.md`, { nodir: true }); return Promise.all( site.map(async (page) => { let file = await read(page, "utf-8");
M index.jsindex.js

@@ -1,3 +1,4 @@

+#!/usr/bin/env bun import double from "./addons/double.js"; //TODO add systemized plugin support import insertJSX from "./insertJSX.js"; import rehypeDocument from "rehype-document";

@@ -15,9 +16,14 @@ import { createSiteIndex } from "./createSiteIndex.js";

import { emptyDir } from "fs-extra"; import cpy from "cpy"; import { glob } from "glob"; +import { resolve } from "path"; -emptyDir("out", { recursive: true }); // clears the output folder -await cpy(["input/**", "!input/**/*{.md,.jsx}"], "out", { flat: true }); //copies all the assets into out/ +const inputDir = resolve(process.cwd(), "input"); +const outputDir = resolve(process.cwd(), "out"); +emptyDir(`${outputDir}`, { recursive: true }); // clears the output folder +await cpy([`${inputDir}/**`, `!${inputDir}/**/*.md`], `${outputDir}`, { + flat: true, +}); //copies all assets into out/ const siteIndex = await createSiteIndex(); export async function kushiyaki(filepath) {

@@ -44,10 +50,10 @@ .use(rehypeStringify);

const output = await processor.process(file); output.extname = ".html"; - output.dirname = "out"; + output.dirname = outputDir; return output; } -for (const file of await glob("input/**/*.md", { nodir: true })) { +for (const file of await glob(`${inputDir}/**/*.md`, { nodir: true })) { await write(await kushiyaki(file)); }
M insertJSX.jsinsertJSX.js

@@ -1,4 +1,5 @@

import { select } from "hast-util-select"; +import { resolve } from "path"; /* * DONE filedata * DONE before/after

@@ -9,17 +10,18 @@ * HACK make the data validation more elegant

*/ export default function insertJSX(data = {}) { const siteIndex = this.data("siteIndex"); // calls siteIndex from the processor + const templateDir = resolve(process.cwd(), "templates"); return async (tree) => { if (data.before != undefined) { for (let x of [data.before].flat().reverse()) { - const fn = await import(`./input/templates/${x}.jsx`); //FIX avoid strict filestruct past "input" + const fn = await import(`${templateDir}/${x}.jsx`); //FIX avoid strict filestruct past "input" tree.children.unshift(fn.default(data, siteIndex)); //TODO use select on "body" } } if (data.after != undefined) { for (let x of [data.after].flat().reverse()) { - const fn = await import(`./input/templates/${x}.jsx`); //FIX avoid strict filestruct past "input" + const fn = await import(`${templateDir}/${x}.jsx`); //FIX avoid strict filestruct past "input" tree.children.push(fn.default(data, siteIndex)); //TODO use select on "body" } }
M package.jsonpackage.json

@@ -10,10 +10,13 @@ },

"homepage": "https://git.trickyni.com/kushiyaki.git", "license": "AGPL-3.0-or-later", "author": "Ricka Hunt <ricka@trickyni.com>", - "type": "commonjs", + "type": "module", "main": "index.js", "scripts": { - "test": "npm run dev" + "dev": "bun index.js && caddy run" + }, + "bin": { + "kushiyaki": "./index.js" }, "keywords": [ "static-site-generator",

@@ -231,7 +234,7 @@ "promise": "^7.3.1",

"property-information": "^7.1.0", "q": "^1.5.1", "queue-microtask": "^1.2.3", - "react": "^19.2.4", + "react": "^19.2.6", "react-dom": "^19.2.4", "react-jsx": "^1.0.0", "readdirp": "^4.1.2",

@@ -329,5 +332,11 @@ "xtend": "^4.0.2",

"yaml": "^2.8.4", "zwitch": "^2.0.4" }, - "devDependencies": {} + "devDependencies": { + "@types/bun": "latest" + }, + "private": true, + "peerDependencies": { + "typescript": "^5" + } }