(notes)
| 311 | |
| 312 | // Folder tree builder (unchanged) |
| 313 | function buildFolderTree(notes) { |
| 314 | const root = {}; |
| 315 | |
| 316 | for (const note of notes) { |
| 317 | const parts = note.folder ? note.folder.split("/") : []; |
| 318 | let node = root; |
| 319 | |
| 320 | for (const part of parts) { |
| 321 | if (!node[part]) node[part] = { __children: {} }; |
| 322 | node = node[part].__children; |
| 323 | } |
| 324 | |
| 325 | if (!node.__files) node.__files = []; |
| 326 | node.__files.push(note); |
| 327 | } |
| 328 | |
| 329 | return root; |
| 330 | } |
| 331 | |
| 332 | const FOLDER_TREE = buildFolderTree(NOTES); |