Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/tiny-docs. quick setup, simple, minimalistic docs for your github project flo-bit.dev/tiny-docs
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import fs from "node:fs";import path from "node:path";
const CONFIG_PATH = "tdocs.config.json";
// Defaults derived from workflow envconst derived = { SITE: process.env.DERIVED_SITE, BASE: process.env.DERIVED_BASE, SITE_NAME: process.env.DERIVED_NAME,
GITHUB_URL: "https://github.com/" + process.env.DERIVED_REPO,
SHOW_THEME_TOGGLE: true, SEARCH_ENABLED: true,
BASE_COLOR: "stone", ACCENT_COLOR: "rose",};
function readExisting(path) { if (!fs.existsSync(path)) return {}; try { const raw = fs.readFileSync(path, "utf8").trim() || "{}"; return JSON.parse(raw); } catch (e) { console.warn( "⚠️ Invalid JSON in tdocs.config.json; continuing with empty object.", ); return {}; }}
function normalize(merged) { if ( typeof merged.BASE === "string" && merged.BASE && !merged.BASE.startsWith("/") ) { merged.BASE = "/" + merged.BASE; } return merged;}
const existing = readExisting(CONFIG_PATH);
// Merge so existing values win; only fill in missing keys from derivedconst merged = normalize({ ...derived, ...existing });
fs.writeFileSync(CONFIG_PATH, JSON.stringify(merged, null, 2) + "\n");console.log( "✅ Wrote tdocs.config.json with keys:", Object.keys(merged).join(", "),);
console.log("\n🔍 Result:\n" + fs.readFileSync(CONFIG_PATH, "utf8"));
function renameMdToMdx(dir = process.cwd()) { // Read all items in the current directory const items = fs.readdirSync(dir, { withFileTypes: true });
for (const item of items) { const fullPath = path.join(dir, item.name);
if (item.isDirectory()) { // Recurse into subdirectories renameMdToMdx(fullPath); } else if (item.isFile() && path.extname(item.name) === ".md") { const newName = path.basename(item.name, ".md") + ".mdx"; const newPath = path.join(dir, newName);
fs.renameSync(fullPath, newPath); console.log(`Renamed: ${fullPath} → ${newPath}`); } }}
// Run the functionrenameMdToMdx();