( relPath: string, body: string, position: 'start' | 'end' )
| 406 | } |
| 407 | |
| 408 | async function appendToNote( |
| 409 | relPath: string, |
| 410 | body: string, |
| 411 | position: 'start' | 'end' |
| 412 | ): Promise<NoteMeta> { |
| 413 | const current = await readNote(relPath) |
| 414 | const trimmed = body.replace(/\s+$/u, '') |
| 415 | if (!trimmed) return current |
| 416 | const next = |
| 417 | position === 'end' |
| 418 | ? `${current.body}${current.body.endsWith('\n') ? '' : '\n'}\n${trimmed}\n` |
| 419 | : `${trimmed}\n\n${current.body}` |
| 420 | return await writeNote(relPath, next) |
| 421 | } |
| 422 | |
| 423 | function createNote( |
| 424 | folder: NoteFolder, |