nomadro/apps/nomadweb/frontend/src/lib/ebook/contentPath.ts
eric 6cae715727 Fix monorepo book content path and exclude Vite entry from portal tsc.
EOF

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 17:20:26 -05:00

25 lines
816 B
TypeScript

import "server-only";
import fs from "fs";
import path from "path";
/** Resolve content/book across next standalone and monorepo layouts */
export function resolveBookContentDir(): string {
const candidates = [
path.join(process.cwd(), "apps", "nomadweb", "frontend", "content", "book"),
path.join(process.cwd(), "content", "book"),
path.join(process.cwd(), "..", "content", "book"),
path.join(process.cwd(), "../..", "content", "book"),
path.join(process.cwd(), "../../..", "content", "book"),
path.join(__dirname, "../../../../content/book"),
path.join(__dirname, "../../../../../content/book"),
];
for (const dir of candidates) {
try {
if (fs.existsSync(path.join(dir, "book.json"))) return dir;
} catch {
/* continue */
}
}
return candidates[0]!;
}