| | |
| | | let toRebuild: Set<FilePath> = new Set() |
| | | let toRemove: Set<FilePath> = new Set() |
| | | async function rebuild(fp: string, action: "add" | "change" | "delete") { |
| | | fp = toPosixPath(fp) |
| | | fp = toPosixPath(fp) |
| | | if (!ignored(fp)) { |
| | | const filePath = joinSegments(argv.directory, fp) as FilePath |
| | | if (action === "add" || action === "change") { |
| | |
| | | clearTimeout(timeoutId) |
| | | } |
| | | |
| | | // debounce rebuilds every 250ms |
| | | timeoutId = setTimeout(async () => { |
| | | const perf = new PerfTimer() |
| | | console.log(chalk.yellow("Detected change, rebuilding...")) |
| | |
| | | |
| | | ctx.allSlugs = [...new Set([...contentMap.keys(), ...toRebuild])] |
| | | .filter((fp) => !toRemove.has(fp)) |
| | | .map((fp) => slugifyFilePath(path.relative(argv.directory, fp) as FilePath)) |
| | | .map((fp) => slugifyFilePath(path.posix.relative(argv.directory, fp) as FilePath)) |
| | | |
| | | const parsedContent = await parseMarkdown(ctx, filesToRebuild) |
| | | for (const content of parsedContent) { |