From 59f392de39b8cb3dcbf2972259fce1cf0f7e9bb4 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 7 Dec 2023 14:37:25 -0800 Subject: [PATCH] feat: share to ollamahub --- src/routes/(app)/modelfiles/+page.svelte | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/routes/(app)/modelfiles/+page.svelte b/src/routes/(app)/modelfiles/+page.svelte index 5887eabb..843e8d1d 100644 --- a/src/routes/(app)/modelfiles/+page.svelte +++ b/src/routes/(app)/modelfiles/+page.svelte @@ -42,6 +42,24 @@ await modelfiles.set($modelfiles.filter((modelfile) => modelfile.tagName != tagName)); localStorage.setItem('modelfiles', JSON.stringify($modelfiles)); }; + + const shareModelfile = async (modelfile) => { + toast.success('Redirecting you to OllamaHub'); + + const url = 'https://ollamahub.com'; + + const tab = await window.open(`${url}/create`, '_blank'); + window.addEventListener( + 'message', + (event) => { + if (event.origin !== url) return; + if (event.data === 'loaded') { + tab.postMessage(JSON.stringify(modelfile), '*'); + } + }, + false + ); + };
@@ -108,6 +126,16 @@ Edit + +