Downtime catalog
This commit is contained in:
15
lib/reasonCatalogFallback.ts
Normal file
15
lib/reasonCatalogFallback.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { readFile } from "fs/promises";
|
||||
import path from "path";
|
||||
import { parseReasonCatalogMarkdown, type ReasonCatalog } from "@/lib/reasonCatalog";
|
||||
|
||||
let catalogPromise: Promise<ReasonCatalog> | null = null;
|
||||
|
||||
/** Server-only: reads downtime_menu.md from the repo root. */
|
||||
export async function loadFallbackReasonCatalog() {
|
||||
if (!catalogPromise) {
|
||||
catalogPromise = readFile(path.join(process.cwd(), "downtime_menu.md"), "utf8")
|
||||
.then((raw) => parseReasonCatalogMarkdown(raw))
|
||||
.catch(() => ({ version: 1, downtime: [], scrap: [] }));
|
||||
}
|
||||
return catalogPromise;
|
||||
}
|
||||
Reference in New Issue
Block a user