(
payload: ImportPayload = {},
)
| 7 | import { applyNotesImportResult } from './persist' |
| 8 | |
| 9 | export function previewObsidianImport( |
| 10 | payload: ImportPayload = {}, |
| 11 | ): ImportPreview { |
| 12 | const result = parseObsidianMarkdownFiles(payload.files || []) |
| 13 | const folders = new Map<string, number>() |
| 14 | const tags = new Map<string, string>() |
| 15 | |
| 16 | result.notes.forEach((note) => { |
| 17 | const folderPath = note.folderPath?.filter(Boolean).join('/') |
| 18 | if (folderPath) { |
| 19 | folders.set(folderPath, (folders.get(folderPath) || 0) + 1) |
| 20 | } |
| 21 | |
| 22 | note.tags?.forEach((tag) => { |
| 23 | tags.set(tag.toLowerCase(), tag) |
| 24 | }) |
| 25 | }) |
| 26 | |
| 27 | return { |
| 28 | folders: [...folders.entries()].map(([path, notes]) => ({ |
| 29 | path, |
| 30 | snippets: notes, |
| 31 | })), |
| 32 | groups: [ |
| 33 | { |
| 34 | name: 'Obsidian', |
| 35 | snippets: result.notes.length, |
| 36 | }, |
| 37 | ], |
| 38 | notes: result.notes.length, |
| 39 | snippets: 0, |
| 40 | source: 'obsidian', |
| 41 | tags: [...tags.values()].sort((a, b) => a.localeCompare(b)), |
| 42 | warnings: result.warnings, |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export function applyObsidianImport( |
| 47 | payload: ImportPayload = {}, |
no test coverage detected