(id, format)
| 79 | }, |
| 80 | |
| 81 | async export(id, format) { |
| 82 | const conv = findConversation(id); |
| 83 | |
| 84 | if (format === "json") { |
| 85 | return new Blob([JSON.stringify(conv, null, 2)], { |
| 86 | type: "application/json", |
| 87 | }); |
| 88 | } |
| 89 | |
| 90 | // Markdown export |
| 91 | const lines: string[] = [`# ${conv.title}`, ""]; |
| 92 | const created = new Date(conv.createdAt).toISOString(); |
| 93 | lines.push(`> Exported from Claude Code · ${created}`, ""); |
| 94 | |
| 95 | for (const msg of conv.messages) { |
| 96 | const heading = |
| 97 | msg.role === "user" |
| 98 | ? "**You**" |
| 99 | : msg.role === "assistant" |
| 100 | ? "**Claude**" |
| 101 | : `**${msg.role}**`; |
| 102 | lines.push(heading, ""); |
| 103 | lines.push(extractTextContent(msg.content), ""); |
| 104 | lines.push("---", ""); |
| 105 | } |
| 106 | |
| 107 | return new Blob([lines.join("\n")], { type: "text/markdown" }); |
| 108 | }, |
| 109 | }; |
nothing calls this directly
no test coverage detected