[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/
0

Configure Feed

Select the types of activity you want to include in your feed.

update rename

+22 -7
+22 -7
scripts/update-config.js
··· 1 1 import fs from "node:fs"; 2 + import path from "node:path"; 2 3 3 4 const CONFIG_PATH = "tdocs.config.json"; 4 5 ··· 52 53 53 54 console.log("\n🔍 Result:\n" + fs.readFileSync(CONFIG_PATH, "utf8")); 54 55 55 - // rename all .md files to .mdx in root folder and subfolders recursively 56 - const mdFiles = fs.readdirSync(".", { withFileTypes: true, recursive: true }) 57 - .filter(dirent => dirent.isFile() && dirent.name.endsWith(".md")) 58 - .map(dirent => dirent.name); 56 + function renameMdToMdx(dir = process.cwd()) { 57 + // Read all items in the current directory 58 + const items = fs.readdirSync(dir, { withFileTypes: true }); 59 59 60 - for (const mdFile of mdFiles) { 61 - fs.renameSync(mdFile, mdFile.replace(".md", ".mdx")); 62 - } 60 + for (const item of items) { 61 + const fullPath = path.join(dir, item.name); 62 + 63 + if (item.isDirectory()) { 64 + // Recurse into subdirectories 65 + renameMdToMdx(fullPath); 66 + } else if (item.isFile() && path.extname(item.name) === ".md") { 67 + const newName = path.basename(item.name, ".md") + ".mdx"; 68 + const newPath = path.join(dir, newName); 69 + 70 + fs.renameSync(fullPath, newPath); 71 + console.log(`Renamed: ${fullPath} → ${newPath}`); 72 + } 73 + } 74 + } 75 + 76 + // Run the function 77 + renameMdToMdx();