| 38 | } |
| 39 | |
| 40 | function getFileInsertText(plugin: TaskNotesPlugin, file: TFile): string { |
| 41 | if (file.extension === "md") { |
| 42 | const linktext = plugin.app.metadataCache.fileToLinktext?.(file, "", true); |
| 43 | if (typeof linktext === "string" && linktext.trim()) { |
| 44 | return linktext; |
| 45 | } |
| 46 | return file.basename; |
| 47 | } |
| 48 | return file.name || file.path.split("/").pop() || file.basename; |
| 49 | } |
| 50 | |
| 51 | function normalizeFolderPath(folder: string): string { |
| 52 | return folder.trim().replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, ""); |