mirror of
https://github.com/luxfi/lpm.git
synced 2026-10-30 16:20:57 +00:00
1 line
2.2 KiB
JavaScript
1 line
2.2 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,10014,t=>{"use strict";function e(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i(t){let i="string"==typeof t?function(t){let i=t.trim();if(0===i.length)return null;let n=Array.from(new Set(i.split(/\s+/).map(t=>t.trim()).filter(Boolean)));if(0===n.length)return null;let r=n.map(e).join("|");return RegExp(`(${r})`,"gi")}(t):t;return{highlight(t){if(!i)return[{type:"text",content:t}];let e=[],n=0;for(let r of t.matchAll(i))n<r.index&&e.push({type:"text",content:t.substring(n,r.index)}),e.push({type:"text",content:r[0],styles:{highlight:!0}}),n=r.index+r[0].length;return n<t.length&&e.push({type:"text",content:t.substring(n)}),e}}}t.s(["createContentHighlighter",()=>i])},2860,t=>{"use strict";t.s(["removeUndefined",()=>function t(e,i=!1){for(let n in e){if(void 0===e[n]&&delete e[n],!i)continue;let r=e[n];if("object"==typeof r&&null!==r){t(r,i);continue}if(Array.isArray(r))for(let e of r)t(e,i)}return e}])},54710,t=>{"use strict";var e=t.i(2860),i=t.i(10014);async function n(t,n){let r=(0,i.createContentHighlighter)(t),l=[],{index:o="default",client:h,params:u={},tag:c}=n;if("crawler"===o){let e=await h.search({...u,term:t,where:{category:c?{eq:c.slice(0,1).toUpperCase()+c.slice(1)}:void 0,...u.where},limit:10});if(!e)return l;for(let t of e.hits){let e=t.document;l.push({id:t.id,type:"page",content:e.title,contentWithHighlights:r.highlight(e.title),url:e.path},{id:"page"+t.id,type:"text",content:e.content,contentWithHighlights:r.highlight(e.content),url:e.path})}return l}let s={...u,term:t,where:(0,e.removeUndefined)({tag:c,...u.where}),groupBy:{properties:["page_id"],maxResult:7,...u.groupBy}},g=await h.search(s);if(!g||!g.groups)return l;for(let t of g.groups){let e=!1;for(let i of t.result){let t=i.document;e||(l.push({id:t.page_id,type:"page",content:t.title,breadcrumbs:t.breadcrumbs,contentWithHighlights:r.highlight(t.title),url:t.url}),e=!0),l.push({id:t.id,content:t.content,contentWithHighlights:r.highlight(t.content),type:t.content===t.section?"heading":"text",url:t.section_id?`${t.url}#${t.section_id}`:t.url})}}return l}t.i(35317),t.s(["searchDocs",()=>n])}]); |