25 lines
816 B
TypeScript
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]!;
|
|
}
|