import { AnalyzeMarkdown } from "./lib/markdown_analyzer.ts"; import { PageRoot } from "./lib/page.ts"; // Function to recursively crawl through the directory and analyze markdown files async function analyzeMarkdownFiles(dir: string, pageInfo: PageRoot): Promise { for await (const entry of Deno.readDir(dir)) { const fullPath = `${dir}/${entry.name}`; if (entry.isDirectory) { // Recurse into subdirectories pageInfo = await analyzeMarkdownFiles(fullPath, pageInfo); } else if (entry.isFile && fullPath.endsWith(".md")) { // Analyze markdown file console.log(`Analyzing: ${fullPath}`); pageInfo.articles.push(await AnalyzeMarkdown(fullPath)); } } return pageInfo; } // Start the crawling process from the `./articles` directory const data = await analyzeMarkdownFiles("./articles", { articles: [], // Something silly in the event someone decides to look at the file // TODO: Put weird shit here. note: `I knew you would look at this file >:3` }); Deno.writeFileSync("./meta.json", new TextEncoder().encode(JSON.stringify(data, null, 2)), {append: false})