(conv: Conversation, options: ExportOptions)
| 115 | `; |
| 116 | |
| 117 | export function toHTML(conv: Conversation, options: ExportOptions): string { |
| 118 | let messages = conv.messages; |
| 119 | if (options.dateRange) { |
| 120 | const { start, end } = options.dateRange; |
| 121 | messages = messages.filter((m) => m.createdAt >= start && m.createdAt <= end); |
| 122 | } |
| 123 | |
| 124 | const metaParts = [ |
| 125 | ...(conv.model ? [`<span>Model: ${escapeHtml(conv.model)}</span>`] : []), |
| 126 | `<span>${messages.length} messages</span>`, |
| 127 | ...(options.includeTimestamps |
| 128 | ? [`<span>Created: ${new Date(conv.createdAt).toLocaleString()}</span>`] |
| 129 | : []), |
| 130 | `<span>Exported: ${new Date().toLocaleString()}</span>`, |
| 131 | ]; |
| 132 | |
| 133 | const messagesHtml = messages |
| 134 | .map((m) => renderMessageHtml(m, options)) |
| 135 | .join("\n"); |
| 136 | |
| 137 | return `<!DOCTYPE html> |
| 138 | <html lang="en"> |
| 139 | <head> |
| 140 | <meta charset="UTF-8" /> |
| 141 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 142 | <title>${escapeHtml(conv.title)} — Claude Code</title> |
| 143 | <style>${CSS}</style> |
| 144 | </head> |
| 145 | <body> |
| 146 | <h1>${escapeHtml(conv.title)}</h1> |
| 147 | <div class="meta">${metaParts.join("")}</div> |
| 148 | <div class="messages">${messagesHtml}</div> |
| 149 | <div class="footer"> |
| 150 | <a href="https://claude.ai/code">Powered by Claude Code</a> |
| 151 | </div> |
| 152 | </body> |
| 153 | </html>`; |
| 154 | } |
no test coverage detected