mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-26 14:24:05 -06:00
1 line
590 B
JavaScript
1 line
590 B
JavaScript
const apiKey="1e47d93b-1468-45b7-98d5-7f733d5e45e2";async function searchContents(e){const t=await fetch("https://prod.operand.ai/v3/search/objects",{method:"POST",headers:{'Content-Type':"application/json",Authorization:apiKey},body:JSON.stringify({query:e,max:10})});return await t.json()}function debounce(t,n=300){let e;return(...s)=>{clearTimeout(e),e=setTimeout(()=>{t.apply(this,s)},n)}}registerHandlers(debounce(e=>{term=e.target.value,searchContents(term).then(e=>e.results.map(e=>({url:e.object.metadata.url,content:e.snippet,title:e.object.title}))).then(e=>displayResults(e))})) |