diff --git a/components/Chat/Chat.tsx b/components/Chat/Chat.tsx
index 5c8f36f..a3ce33a 100644
--- a/components/Chat/Chat.tsx
+++ b/components/Chat/Chat.tsx
@@ -1,4 +1,9 @@
-import { IconClearAll, IconSettings, IconPdf } from '@tabler/icons-react';
+import {
+ IconClearAll,
+ IconSettings,
+ IconMarkdown,
+ IconPdf
+} from '@tabler/icons-react';
import {
MutableRefObject,
memo,
@@ -303,6 +308,30 @@ export const Chat = memo(({ stopConversationRef }: Props) => {
}
};
+ const onMarkdown = () => {
+ if (!selectedConversation){
+ return '';
+ }
+ let markdownContent = '';
+
+ selectedConversation.messages.forEach(obj => {
+ markdownContent += `## ${obj.role === "user" ? t('You') : t("AI")}\n\n${obj.content}\n\n`;
+ });
+
+ const date = new Date().toLocaleString("default", { year: "numeric", month: "long", day: "numeric" })
+ const time = new Date().toLocaleTimeString("default", {hour12: true, hour: "numeric", minute: "numeric"})
+
+ markdownContent += `---\n`
+ markdownContent += `${t("Exported on")} ` + date + ` ${t("at")} ` + time + ".";
+
+ const markdownFile = new Blob([markdownContent], { type: 'text/markdown' });
+ const downloadLink = document.createElement('a');
+
+ downloadLink.href = URL.createObjectURL(markdownFile);
+ downloadLink.download = `${selectedConversation?.name || 'conversation'}.md`;
+ downloadLink.click();
+ }
+
const onPdf = () => {
if (chatContainerRef.current === null) {
return;
@@ -485,6 +514,12 @@ export const Chat = memo(({ stopConversationRef }: Props) => {
>
+