all repos — kushiyaki @ 114a3775a7823e4bef25809bd91dfc86033b1b61

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

chore: delete deprecated files
trickyni trickyniv56@gmail.com
Tue, 19 May 2026 14:40:41 +0300
commit

114a3775a7823e4bef25809bd91dfc86033b1b61

parent

f4b397cf4191686ae7541fcd0986d611d9c7b0ca

7 files changed, 0 insertions(+), 430 deletions(-)

jump to
D deprecated/extractContent.js

@@ -1,26 +0,0 @@

-import { readFile, writeFile } from "fs-extra"; -import { unified } from "unified"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; -import rehypeStringify from "rehype-stringify"; -import remarkFrontmatter from "remark-frontmatter"; -import rehypeFormat from "rehype-format"; -import rehypeRaw from "rehype-raw"; -// -//NOTE input: markdown file. output, HTML fragment -// - -export async function extractContent(filepath) { - let content; - const processor = await unified() - .use(remarkParse) - .use(remarkRehype, { allowDangerousHtml: true }) - .use(rehypeRaw) - .use(remarkFrontmatter) - .use(rehypeFormat) - .use(rehypeStringify) - .process(await readFile(filepath, "utf-8")); - return processor.value; -} - -console.log(await extractContent("./input/cookie.md"));
D deprecated/frontmatterJson.js

@@ -1,54 +0,0 @@

-import rehypeStringify from "rehype-stringify"; -import remarkFrontmatter from "remark-frontmatter"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; -import { unified } from "unified"; -import { readdir, readFile, writeFile } from "fs-extra"; - -export async function frontmatterJson(path) { - let output = []; - - // NOTE Reads the content folder - const inputFolder = await readdir(path, { - recursive: true, - withFileTypes: true, - }); - - // NOTE Iterates over content files - for (let file of inputFolder) { - if (file.isFile()) { - let filepath = file.path + "/" + file.name; - console.log(filepath); - output.push(await parseFrontmatter(filepath)); - } - } - - output - .sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()) - .reverse(); - return output; -} - -// NOTE builds the Markdown --> HTML processor -async function parseFrontmatter(filepath) { - let meow; - let frontmatter; - const processor = unified() - .use(remarkParse) - .use(remarkFrontmatter, "yaml") - .use(() => (tree) => { - frontmatter = tree.children[0].value; - if (tree.children[0].type == "yaml") { - frontmatter = Object.fromEntries( - frontmatter.split("\n").map((line) => line.split(": ")), - ); - frontmatter.permalink ??= filepath.split("/").pop().replace(".md", ""); - meow = frontmatter; - } else { - console.error(" ERROR: Frontmatter not found"); - process.exit(); - } - }); - processor.run(processor.parse(await readFile(filepath, "utf8"))); - return meow; -}
D deprecated/frontmatterJson_flat.js

@@ -1,54 +0,0 @@

-import rehypeStringify from "rehype-stringify"; -import remarkFrontmatter from "remark-frontmatter"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; -import { unified } from "unified"; -import { readdir, readFile, writeFile } from "fs-extra"; - -export async function frontmatterJson(path) { - let output = []; - - // NOTE Reads the content folder - const inputFolder = await readdir(path, { - recursive: true, - withFileTypes: true, - }); - - // NOTE Iterates over content files - for (let file of inputFolder) { - if (file.isFile()) { - let filepath = file.path + "/" + file.name; - console.log(filepath); - output.push(await parseFrontmatter(filepath)); - } - } - - output - .sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()) - .reverse(); - return output; -} - -// NOTE builds the Markdown --> HTML processor -async function parseFrontmatter(filepath) { - let meow; - let frontmatter; - const processor = unified() - .use(remarkParse) - .use(remarkFrontmatter, "yaml") - .use(() => (tree) => { - frontmatter = tree.children[0].value; - if (tree.children[0].type == "yaml") { - frontmatter = Object.fromEntries( - frontmatter.split("\n").map((line) => line.split(": ")), - ); - frontmatter.permalink ??= filepath.split("/").pop().replace(".md", ""); - meow = frontmatter; - } else { - console.error(" ERROR: Frontmatter not found"); - process.exit(); - } - }); - processor.run(processor.parse(await readFile(filepath, "utf8"))); - return meow; -}
D deprecated/jsxEmbeder.js

@@ -1,32 +0,0 @@

-import { markdownObj } from "./markdownObj"; -import { unified } from "unified"; -import rehypeFormat from "rehype-format"; -import rehypeStringify from "rehype-stringify"; -import baseline from "./input/baseline.jsx"; -import { readFile } from "fs-extra"; -import { extractContent } from "./deprecated/extractContent.js"; -import rehypeParse from "rehype-parse"; - -const jsxProcessor = unified() - .use(rehypeParse, { fragment: true }) - .use(rehypeFormat) - .use(rehypeStringify); -// -//FIX seems to be an issue with the pipeline, run it and you'll see whats up -// -// const file = await markdownObj("./input/cookie.md"); -const main = await extractContent("./input/cookie.md"); -// console.log(file.main); -const output = await jsxProcessor.stringify( - await jsxProcessor.run( - baseline({ - // css: file.css, - // header: eval(file.header)?.(file), - // before: eval(file.before)?.(file), - main: main, - // after: eval(file.after)?.(file), - // footer: eval(file.footer)?.(file), - }), - ), -); -console.log(output);
D deprecated/markdownObj.js

@@ -1,38 +0,0 @@

-import { unified } from "unified"; -import { readFile } from "fs-extra"; -import remarkStringify from "remark-stringify"; -import remarkRehype from "remark-rehype"; -import remarkParse from "remark-parse"; -import remarkFrontmatter from "remark-frontmatter"; -import rehypeStringify from "rehype-stringify"; -import rehypeFormat from "rehype-format"; -import rehypeRaw from "rehype-raw"; -const yaml = require("js-yaml"); - -//NOTE This function takes a markdown, flattens the frontmatter into an object, -// then parses the body into a HAST (HTML) string and adds it into the object. -// The markdown is carved into simple components, which will later be slotted -// into JSX components -// - -export async function markdownObj(filepath) { - let output; - const processor = await unified() - .use(remarkParse) - .use(remarkFrontmatter, "yaml") - .use(() => (tree) => { - output = yaml.load(tree.children[0].value); - //TODO throw error on invalid frontmatter - }) - .use(remarkRehype) - .use(rehypeFormat) - .use(rehypeStringify) - //TODO throw error if frontmatter already contains main (or other reserved properties) - .process(await readFile(filepath, "utf-8")); - output.filename = filepath.split("/").pop(); //adds the input filename into the object - output.main = processor.value; - console.log(output); - return output; -} - -markdownObj("./input/cookie.md");
D deprecated/write_website.js

@@ -1,123 +0,0 @@

-import rehypeFormat from "rehype-format"; -import rehypeRaw from "rehype-raw"; -import rehypeStringify from "rehype-stringify"; -import remarkFrontmatter from "remark-frontmatter"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; -import { unified } from "unified"; -import { read } from "to-vfile"; -import { - copy, - emptyDir, - ensureDir, - readFile, - writeFile, - readdir, -} from "fs-extra"; -import double from "./src/double"; -import { argv0 } from "process"; -import { frontmatterJson } from "./frontmatterJson"; -import poetryIndex from "./src/poetryIndex.jsx"; -import baseline from "./src/baseline.jsx"; -import booknav from "./src/booknav.jsx"; -import gallery from "./src/gallery.jsx"; -import picture from "./src/picture.jsx"; -import h2 from "./src/h2.jsx"; -import home from "./src/home.jsx"; -import recipeIndex from "./src/recipeIndex.jsx"; -import sharp from "sharp"; -let frontmatter; - -// builds the Markdown --> HTML processor -const processor = unified() - .use(remarkParse) - .use(remarkFrontmatter, "yaml") - // frontmatter - .use(() => (tree) => { - frontmatter = tree.children[0].value; - if (tree.children[0].type == "yaml") { - frontmatter = Object.fromEntries( - frontmatter.split("\n").map((line) => line.split(": ")), - ); - } else { - console.error(" ERROR: Frontmatter not found"); - process.exit(); - } - }) - - .use(double) - .use(remarkRehype, { allowDangerousHtml: true }) - .use(rehypeRaw) - .use(rehypeFormat) - // turn hast tree into string - // consider: add this tree as child to JSX produced tree - .use(rehypeStringify); - -// clears out the output directory and copies static files into it. -await emptyDir("out", { recursive: true }); -await copy("css", "out/css"); -await copy("static", "out/static"); -// Reads the content folder -const input = await readdir("./content/", { - recursive: true, - withFileTypes: true, -}); - -// Iterates over the content folder's subdirectories and ensures they are made -for (let folder of input) { - if (folder.isDirectory()) { - let outpath = folder.path.replace("content", "out") + "/" + folder.name; - await ensureDir(outpath); - console.log("Created: " + outpath); - } -} - -const jsxProcessor = unified() - .use(rehypeFormat) - // turn hast tree into string - // consider: add this tree as child to JSX produced tree - .use(rehypeStringify); - -// Iterates over content files -for (let file of input) { - if (file.isFile()) { - let filepath = file.path + "/" + file.name; - const input_file = await readFile(filepath, "utf8"); - console.log(filepath); - - // Invokes Markdown --> HTML Processor - console.log(" " + filepath + " parsing"); - let parsed_input = await processor.run(await processor.parse(input_file)); - // builds layout - // const layoutMain = eval(frontmatter.main)({}); - - // parses JSX HACK - const markdown = () => parsed_input; - const output = await jsxProcessor.stringify( - await jsxProcessor.run( - baseline({ - css: frontmatter.css, - header: eval(frontmatter.header)?.(frontmatter), - before: eval(frontmatter.before)?.(frontmatter), - main: markdown(), - after: eval(frontmatter.after)?.(frontmatter), - footer: eval(frontmatter.footer)?.(frontmatter), - }), - ), - ); - - // Writes output to a new HTML file - await writeFile( - file.path.replace("content", "out") + - "/" + - file.name.split(".")[0] + - ".html", - String(output), - "utf8", - ); - console.log(" " + filepath + " written"); - console.log(frontmatter); - } -} - -console.log("\n----- WRITING COMPLETE -----");
D deprecated/write_website_flat.js

@@ -1,103 +0,0 @@

-import rehypeFormat from "rehype-format"; -import rehypeRaw from "rehype-raw"; -import rehypeStringify from "rehype-stringify"; -import remarkFrontmatter from "remark-frontmatter"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; -import { unified } from "unified"; -import { read } from "to-vfile"; -import { - copy, - emptyDir, - ensureDir, - readFile, - writeFile, - readdir, -} from "fs-extra"; -import { argv0 } from "process"; -import baseline from "./input/baseline.jsx"; -let frontmatter; - -// builds the Markdown --> HTML processor -const processor = unified() - .use(remarkParse) - .use(remarkFrontmatter, "yaml") - // frontmatter - .use(() => (tree) => { - frontmatter = tree.children[0].value; - if (tree.children[0].type == "yaml") { - frontmatter = Object.fromEntries( - frontmatter.split("\n").map((line) => line.split(": ")), - ); - console.log(frontmatter); - } else { - console.error(" ERROR: Frontmatter not found"); - process.exit(); - } - }); - - .use(remarkRehype, { allowDangerousHtml: true }) - .use(rehypeRaw) - .use(rehypeFormat) - // turn hast tree into string - // consider: add this tree as child to JSX produced tree - .use(rehypeStringify); - -// clears out the output directory and copies static files into it. -await emptyDir("out", { recursive: true }); -// await copy("css", "out/css"); -// await copy("static", "out/static"); -// Reads the content folder -const input = await readdir("./input/", { - recursive: true, - withFileTypes: true, -}); -const jsxProcessor = unified() - .use(rehypeFormat) - // turn hast tree into string - // consider: add this tree as child to JSX produced tree - .use(rehypeStringify); - -// Iterates over content files -for (let file of input) { - if (file.isFile()) { - let filepath = file.path + "/" + file.name; - const input_file = await readFile(filepath, "utf8"); - console.log(filepath); - - // Invokes Markdown --> HTML Processor - console.log(" " + filepath + " parsing"); - let parsed_input = await processor.run(await processor.parse(input_file)); - // builds layout - // const layoutMain = eval(frontmatter.main)({}); - - // parses JSX HACK - const markdown = () => parsed_input; - const output = await jsxProcessor.stringify( - await jsxProcessor.run( - baseline({ - css: frontmatter.css, - header: eval(frontmatter.header)?.(frontmatter), - before: eval(frontmatter.before)?.(frontmatter), - main: markdown(), - after: eval(frontmatter.after)?.(frontmatter), - footer: eval(frontmatter.footer)?.(frontmatter), - }), - ), - ); - - // Writes output to a new HTML file - await writeFile( - file.path.replace("content", "out") + - "/" + - file.name.split(".")[0] + - ".html", - String(output), - "utf8", - ); - console.log(" " + filepath + " written"); - console.log(frontmatter); - } -} - -console.log("\n----- WRITING COMPLETE -----");