diff --git a/src/lib/components/layout/Navbar.svelte b/src/lib/components/layout/Navbar.svelte index e6154a84..70e39eb7 100644 --- a/src/lib/components/layout/Navbar.svelte +++ b/src/lib/components/layout/Navbar.svelte @@ -2,10 +2,31 @@ import { v4 as uuidv4 } from 'uuid'; import { goto } from '$app/navigation'; - import { chatId } from '$lib/stores'; + import { chatId, db } from '$lib/stores'; + import toast from 'svelte-french-toast'; export let title: string = 'Ollama Web UI'; export let shareEnabled: boolean = false; + + const shareChat = async () => { + const chat = await $db.getChatById($chatId); + console.log('share', chat); + toast.success('Redirecting you to OllamaHub'); + + const url = 'https://ollamahub.com'; + + const tab = await window.open(`${url}/chats/upload`, '_blank'); + window.addEventListener( + 'message', + (event) => { + if (event.origin !== url) return; + if (event.data === 'loaded') { + tab.postMessage(JSON.stringify(chat), '*'); + } + }, + false + ); + };