mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 23:04:05 -06:00
1 line
732 B
JavaScript
1 line
732 B
JavaScript
import{operandClient,indexIDHeaderKey,}from"https://unpkg.com/@operandinc/sdk@4.1.3/dist/esm/index.js";const apiKey="jp9k5hudse2a828z98kxd6z3payi8u90rnje",indexId="s0kf3bd6tldw",operand=operandClient(ObjectService,apiKey,"https://api.operand.ai",{[indexIDHeaderKey]:indexId});async function searchContents(t){const e=await operand.searchWithin({query:t,limit:10});return console.log(e.matches),e.matches.flat()}function debounce(t,n=200){let e;return(...s)=>{clearTimeout(e),e=setTimeout(()=>{t.apply(this,s)},n)}}registerHandlers(debounce(e=>{term=e.target.value,term!==""&&searchContents(term).then(e=>e.results.map(e=>({url:e.object.properties.url,content:e.snippet,title:e.object.metadata.title}))).then(e=>displayResults(e))})) |