import fs from 'fs'; import path from 'path'; import yaml from 'js-yaml'; const dbPath = path.resolve(process.cwd(), 'app/dashboard.yml'); export interface DashboardItem { id: string; type: 'folder' | 'link'; parentId: string | null; name?: string; slug?: string; title?: string; url?: string; description?: string; icon?: string; color?: string; order: number; } export function readDb(): DashboardItem[] { if (!fs.existsSync(dbPath)) { return []; } const fileContents = fs.readFileSync(dbPath, 'utf8'); return (yaml.load(fileContents) as DashboardItem[]) || []; } export function writeDb(data: DashboardItem[]) { const yamlStr = yaml.dump(data); fs.writeFileSync(dbPath, yamlStr, 'utf8'); }