site-data/scripts/update.ts
Seven Of Aces 01b5f4ab80
Some checks failed
Update meta.json / update (push) Failing after 20s
meow
2025-01-15 19:56:01 -08:00

30 lines
No EOL
1.2 KiB
TypeScript

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<PageRoot> {
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})