(filePath: string)
| 213 | * Download a file from its path |
| 214 | */ |
| 215 | export async function downloadFile(filePath: string): Promise<boolean> { |
| 216 | try { |
| 217 | const response = await fetch(`${REPO_BASE_URL}/${filePath}`); |
| 218 | if (!response.ok) throw new Error("Failed to fetch file"); |
| 219 | |
| 220 | const content = await response.text(); |
| 221 | const filename = filePath.split("/").pop() || "file.md"; |
| 222 | |
| 223 | const blob = new Blob([content], { type: "text/markdown" }); |
| 224 | triggerBlobDownload(blob, filename); |
| 225 | |
| 226 | return true; |
| 227 | } catch (error) { |
| 228 | console.error("Download failed:", error); |
| 229 | return false; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Share/copy link to clipboard (deep link to current page with file hash) |
no test coverage detected