@robindoc/minisearch 3.6.4 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,18 @@
1
1
  import { type Searcher } from "./types";
2
+ /**
3
+ * Creates a searcher function that loads and queries a static search index.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { createStaticSearcher } from "@robindoc/minisearch";
8
+ *
9
+ * const searcher = createStaticSearcher("/search-index.json");
10
+ *
11
+ * // Use with Header component
12
+ * <Header searcher={searcher} />
13
+ * ```
14
+ *
15
+ * @see {@link https://robindoc.com/docs/customization/search Search integration}
16
+ */
2
17
  export declare const createStaticSearcher: (indexUrl: string) => Searcher;
3
18
  //# sourceMappingURL=create-static-searcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-static-searcher.d.ts","sourceRoot":"","sources":["../src/create-static-searcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAyC,MAAM,SAAS,CAAC;AA2B/E,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,KAAG,QA8BvD,CAAC"}
1
+ {"version":3,"file":"create-static-searcher.d.ts","sourceRoot":"","sources":["../src/create-static-searcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAyC,MAAM,SAAS,CAAC;AA2B/E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,KAAG,QA8BvD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-static-searcher.js","sources":["../src/create-static-searcher.ts"],"sourcesContent":["import MiniSearch, { type AsPlainObject } from \"minisearch\";\n\nimport { type Searcher, type SearchItem, type SearchIndexItem } from \"./types\";\n\nlet cachedIndex: MiniSearch<SearchIndexItem> | null = null;\n\nconst loadSearchIndex = async (indexUrl: string): Promise<MiniSearch<SearchIndexItem>> => {\n if (cachedIndex) return cachedIndex;\n\n const response = await fetch(indexUrl);\n if (!response.ok) {\n throw new Error(`Failed to load search index: ${response.statusText}`);\n }\n\n const data: AsPlainObject = await response.json();\n const searchIndex = await MiniSearch.loadJSAsync(data, {\n fields: [\"title\", \"content\", \"headings\", \"description\"],\n storeFields: [\"id\", \"title\", \"href\", \"headings\", \"description\"],\n searchOptions: {\n boost: { title: 5, headings: 3, description: 2 },\n fuzzy: 0.2,\n },\n });\n\n cachedIndex = searchIndex;\n\n return searchIndex;\n};\n\nexport const createStaticSearcher = (indexUrl: string): Searcher => {\n return async (search: string, abortController: AbortController): Promise<SearchItem[]> => {\n if (!search.trim()) return [];\n\n try {\n const searchIndex = await loadSearchIndex(indexUrl);\n\n if (abortController.signal.aborted) return [];\n\n const results = searchIndex.search(search, {\n fuzzy: 0.2,\n prefix: true,\n boost: { title: 5, headings: 3, description: 2 },\n });\n\n if (abortController.signal.aborted) return [];\n\n return results.slice(0, 10).map((result) => ({\n title: result.title,\n href: result.href,\n description: result.description,\n }));\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n return [];\n }\n console.error(\"Search error:\", error);\n return [];\n }\n };\n};\n"],"names":["cachedIndex","createStaticSearcher","indexUrl","async","search","abortController","trim","searchIndex","response","fetch","ok","Error","statusText","data","json","MiniSearch","loadJSAsync","fields","storeFields","searchOptions","boost","title","headings","description","fuzzy","loadSearchIndex","signal","aborted","results","prefix","slice","map","result","href","error","name","console"],"mappings":"0BAIA,IAAIA,EAAkD,KAEtD,MAuBaC,EAAwBC,GAC1BC,MAAOC,EAAgBC,KAC1B,IAAKD,EAAOE,OAAQ,MAAO,GAE3B,IACI,MAAMC,OA5BMJ,OAAOD,IAC3B,GAAIF,EAAa,OAAOA,EAExB,MAAMQ,QAAiBC,MAAMP,GAC7B,IAAKM,EAASE,GACV,MAAM,IAAIC,MAAM,gCAAgCH,EAASI,cAG7D,MAAMC,QAA4BL,EAASM,OACrCP,QAAoBQ,EAAWC,YAAYH,EAAM,CACnDI,OAAQ,CAAC,QAAS,UAAW,WAAY,eACzCC,YAAa,CAAC,KAAM,QAAS,OAAQ,WAAY,eACjDC,cAAe,CACXC,MAAO,CAAEC,MAAO,EAAGC,SAAU,EAAGC,YAAa,GAC7CC,MAAO,MAMf,OAFAxB,EAAcO,EAEPA,GAQ2BkB,CAAgBvB,GAE1C,GAAIG,EAAgBqB,OAAOC,QAAS,MAAO,GAE3C,MAAMC,EAAUrB,EAAYH,OAAOA,EAAQ,CACvCoB,MAAO,GACPK,QAAQ,EACRT,MAAO,CAAEC,MAAO,EAAGC,SAAU,EAAGC,YAAa,KAGjD,OAAIlB,EAAgBqB,OAAOC,QAAgB,GAEpCC,EAAQE,MAAM,EAAG,IAAIC,IAAKC,IAAM,CACnCX,MAAOW,EAAOX,MACdY,KAAMD,EAAOC,KACbV,YAAaS,EAAOT,cAE5B,CAAE,MAAOW,GACL,OAAIA,aAAiBvB,OAAwB,eAAfuB,EAAMC,MAGpCC,QAAQF,MAAM,gBAAiBA,GAFpB,EAIf"}
1
+ {"version":3,"file":"create-static-searcher.js","sources":["../src/create-static-searcher.ts"],"sourcesContent":["import MiniSearch, { type AsPlainObject } from \"minisearch\";\n\nimport { type Searcher, type SearchItem, type SearchIndexItem } from \"./types\";\n\nlet cachedIndex: MiniSearch<SearchIndexItem> | null = null;\n\nconst loadSearchIndex = async (indexUrl: string): Promise<MiniSearch<SearchIndexItem>> => {\n if (cachedIndex) return cachedIndex;\n\n const response = await fetch(indexUrl);\n if (!response.ok) {\n throw new Error(`Failed to load search index: ${response.statusText}`);\n }\n\n const data: AsPlainObject = await response.json();\n const searchIndex = await MiniSearch.loadJSAsync(data, {\n fields: [\"title\", \"content\", \"headings\", \"description\"],\n storeFields: [\"id\", \"title\", \"href\", \"headings\", \"description\"],\n searchOptions: {\n boost: { title: 5, headings: 3, description: 2 },\n fuzzy: 0.2,\n },\n });\n\n cachedIndex = searchIndex;\n\n return searchIndex;\n};\n\n/**\n * Creates a searcher function that loads and queries a static search index.\n *\n * @example\n * ```ts\n * import { createStaticSearcher } from \"@robindoc/minisearch\";\n *\n * const searcher = createStaticSearcher(\"/search-index.json\");\n *\n * // Use with Header component\n * <Header searcher={searcher} />\n * ```\n *\n * @see {@link https://robindoc.com/docs/customization/search Search integration}\n */\nexport const createStaticSearcher = (indexUrl: string): Searcher => {\n return async (search: string, abortController: AbortController): Promise<SearchItem[]> => {\n if (!search.trim()) return [];\n\n try {\n const searchIndex = await loadSearchIndex(indexUrl);\n\n if (abortController.signal.aborted) return [];\n\n const results = searchIndex.search(search, {\n fuzzy: 0.2,\n prefix: true,\n boost: { title: 5, headings: 3, description: 2 },\n });\n\n if (abortController.signal.aborted) return [];\n\n return results.slice(0, 10).map((result) => ({\n title: result.title,\n href: result.href,\n description: result.description,\n }));\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n return [];\n }\n console.error(\"Search error:\", error);\n return [];\n }\n };\n};\n"],"names":["cachedIndex","createStaticSearcher","indexUrl","async","search","abortController","trim","searchIndex","response","fetch","ok","Error","statusText","data","json","MiniSearch","loadJSAsync","fields","storeFields","searchOptions","boost","title","headings","description","fuzzy","loadSearchIndex","signal","aborted","results","prefix","slice","map","result","href","error","name","console"],"mappings":"0BAIA,IAAIA,EAAkD,KAEtD,MAsCaC,EAAwBC,GAC1BC,MAAOC,EAAgBC,KAC1B,IAAKD,EAAOE,OAAQ,MAAO,GAE3B,IACI,MAAMC,OA3CMJ,OAAOD,IAC3B,GAAIF,EAAa,OAAOA,EAExB,MAAMQ,QAAiBC,MAAMP,GAC7B,IAAKM,EAASE,GACV,MAAM,IAAIC,MAAM,gCAAgCH,EAASI,cAG7D,MAAMC,QAA4BL,EAASM,OACrCP,QAAoBQ,EAAWC,YAAYH,EAAM,CACnDI,OAAQ,CAAC,QAAS,UAAW,WAAY,eACzCC,YAAa,CAAC,KAAM,QAAS,OAAQ,WAAY,eACjDC,cAAe,CACXC,MAAO,CAAEC,MAAO,EAAGC,SAAU,EAAGC,YAAa,GAC7CC,MAAO,MAMf,OAFAxB,EAAcO,EAEPA,GAuB2BkB,CAAgBvB,GAE1C,GAAIG,EAAgBqB,OAAOC,QAAS,MAAO,GAE3C,MAAMC,EAAUrB,EAAYH,OAAOA,EAAQ,CACvCoB,MAAO,GACPK,QAAQ,EACRT,MAAO,CAAEC,MAAO,EAAGC,SAAU,EAAGC,YAAa,KAGjD,OAAIlB,EAAgBqB,OAAOC,QAAgB,GAEpCC,EAAQE,MAAM,EAAG,IAAIC,IAAKC,IAAM,CACnCX,MAAOW,EAAOX,MACdY,KAAMD,EAAOC,KACbV,YAAaS,EAAOT,cAE5B,CAAE,MAAOW,GACL,OAAIA,aAAiBvB,OAAwB,eAAfuB,EAAMC,MAGpCC,QAAQF,MAAM,gBAAiBA,GAFpB,EAIf"}
@@ -1,3 +1,21 @@
1
1
  import { type GetPageDataFunction, type GetStaticParamsFunction } from "./types";
2
+ /**
3
+ * Generates a static search index from all documentation pages.
4
+ * Processes markdown content and creates a MiniSearch index file.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { generateSearchIndex } from "@robindoc/minisearch";
9
+ * import { getStaticParams, getPageData } from "./robindoc";
10
+ *
11
+ * await generateSearchIndex(
12
+ * getStaticParams,
13
+ * getPageData,
14
+ * "./public/search-index.json"
15
+ * );
16
+ * ```
17
+ *
18
+ * @see {@link https://robindoc.com/docs/customization/search Search integration}
19
+ */
2
20
  export declare const generateSearchIndex: (getStaticParams: GetStaticParamsFunction, getPageData: GetPageDataFunction, outputPath: string) => Promise<void>;
3
21
  //# sourceMappingURL=generate-search-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-search-index.d.ts","sourceRoot":"","sources":["../src/generate-search-index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,uBAAuB,EAAwB,MAAM,SAAS,CAAC;AA6DvG,eAAO,MAAM,mBAAmB,GAC5B,iBAAiB,uBAAuB,EACxC,aAAa,mBAAmB,EAChC,YAAY,MAAM,KACnB,OAAO,CAAC,IAAI,CAwCd,CAAC"}
1
+ {"version":3,"file":"generate-search-index.d.ts","sourceRoot":"","sources":["../src/generate-search-index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,uBAAuB,EAAwB,MAAM,SAAS,CAAC;AA6DvG;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,GAC5B,iBAAiB,uBAAuB,EACxC,aAAa,mBAAmB,EAChC,YAAY,MAAM,KACnB,OAAO,CAAC,IAAI,CAwCd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-search-index.js","sources":["../src/generate-search-index.ts"],"sourcesContent":["import { writeFile, mkdir } from \"fs/promises\";\nimport { lexer, type Token } from \"marked\";\nimport { dirname } from \"path\";\nimport MiniSearch from \"minisearch\";\nimport matter from \"gray-matter\";\n\nimport { type GetPageDataFunction, type GetStaticParamsFunction, type SearchIndexItem } from \"./types\";\n\nconst parseTokenText = (token: Token): string => {\n if (!token) return \"\";\n\n if (\"tokens\" in token) {\n return token.tokens?.map((el: Token) => parseTokenText(el)).join(\"\") || \"\";\n }\n\n if (\"text\" in token) {\n return token.text;\n }\n\n if (\"raw\" in token) {\n return token.raw;\n }\n\n return \"\";\n};\n\nconst parseMarkdownContent = (rawContent: string) => {\n const { content: matterContent, data: matterData } = matter(rawContent);\n const tokens = lexer(matterContent.trim());\n\n let title = matterData.title || \"\";\n let description = matterData.description || \"\";\n const plainTextParts: string[] = [];\n\n const headings: string[] = [];\n tokens.forEach((token: Token) => {\n if (token.type === \"heading\") {\n const headingText = parseTokenText(token);\n if (headingText) {\n if (!title) title = headingText;\n headings.push(headingText);\n plainTextParts.push(headingText);\n }\n return;\n }\n if (token.type === \"paragraph\") {\n const paragraphText = parseTokenText(token);\n if (paragraphText) {\n if (!description) description = paragraphText;\n plainTextParts.push(paragraphText);\n }\n return;\n }\n if ([\"list\", \"blockquote\", \"table\"].includes(token.type)) {\n plainTextParts.push(parseTokenText(token));\n return;\n }\n });\n\n return {\n title,\n description,\n headings: headings.join(\" \").trim(),\n plainText: plainTextParts.join(\" \").trim(),\n };\n};\n\nexport const generateSearchIndex = async (\n getStaticParams: GetStaticParamsFunction,\n getPageData: GetPageDataFunction,\n outputPath: string,\n): Promise<void> => {\n const searchItems: SearchIndexItem[] = [];\n\n const staticParams = await getStaticParams();\n\n for (const staticParam of staticParams) {\n const pathname = `/${staticParam.segments.join(\"/\")}`;\n try {\n const pageData = await getPageData(pathname);\n\n if (!pageData) continue;\n\n const parsed = parseMarkdownContent(pageData.raw);\n const title = pageData.title || parsed.title;\n const description = parsed.description || parsed.plainText.substring(0, 200).trim();\n\n searchItems.push({\n id: pathname,\n title,\n href: pathname,\n headings: parsed.headings,\n content: parsed.plainText,\n description,\n });\n } catch (error) {\n console.warn(`Failed to index page ${pathname}:`, error);\n }\n }\n\n const searchIndex = new MiniSearch<SearchIndexItem>({\n fields: [\"title\", \"content\", \"headings\", \"description\"],\n storeFields: [\"id\", \"title\", \"href\", \"headings\", \"description\"],\n searchOptions: {\n boost: { title: 5, headings: 3, description: 2 },\n fuzzy: 0.2,\n },\n });\n\n await Promise.all([searchIndex.addAllAsync(searchItems), mkdir(dirname(outputPath), { recursive: true })]);\n await writeFile(outputPath, JSON.stringify(searchIndex.toJSON()), \"utf-8\");\n};\n"],"names":["parseTokenText","token","tokens","map","el","join","text","raw","parseMarkdownContent","rawContent","content","matterContent","data","matterData","matter","lexer","trim","title","description","plainTextParts","headings","forEach","type","headingText","push","paragraphText","includes","plainText","generateSearchIndex","async","getStaticParams","getPageData","outputPath","searchItems","staticParams","staticParam","pathname","segments","pageData","parsed","substring","id","href","error","console","warn","searchIndex","MiniSearch","fields","storeFields","searchOptions","boost","fuzzy","Promise","all","addAllAsync","mkdir","dirname","recursive","writeFile","JSON","stringify","toJSON"],"mappings":"sKAQA,MAAMA,EAAkBC,GACfA,EAED,WAAYA,EACLA,EAAMC,QAAQC,IAAKC,GAAcJ,EAAeI,IAAKC,K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CAAE,MAAOyB,GACLC,QAAQC,KAAK,wBAAwBT,KAAaO,EACtD,CACJ,CAEA,MAAMG,EAAc,IAAIC,EAA4B,CAChDC,OAAQ,CAAC,QAAS,UAAW,WAAY,eACzCC,YAAa,CAAC,KAAM,QAAS,OAAQ,WAAY,eACjDC,cAAe,CACXC,MAAO,CAAElC,MAAO,EAAGG,SAAU,EAAGF,YAAa,GAC7CkC,MAAO,YAITC,QAAQC,IAAI,CAACR,EAAYS,YAAYtB,GAAcuB,EAAMC,EAAQzB,GAAa,CAAE0B,WAAW,YAC3FC,EAAU3B,EAAY4B,KAAKC,UAAUf,EAAYgB,UAAW"}
1
+ {"version":3,"file":"generate-search-index.js","sources":["../src/generate-search-index.ts"],"sourcesContent":["import { writeFile, mkdir } from \"fs/promises\";\nimport { lexer, type Token } from \"marked\";\nimport { dirname } from \"path\";\nimport MiniSearch from \"minisearch\";\nimport matter from \"gray-matter\";\n\nimport { type GetPageDataFunction, type GetStaticParamsFunction, type SearchIndexItem } from \"./types\";\n\nconst parseTokenText = (token: Token): string => {\n if (!token) return \"\";\n\n if (\"tokens\" in token) {\n return token.tokens?.map((el: Token) => parseTokenText(el)).join(\"\") || \"\";\n }\n\n if (\"text\" in token) {\n return token.text;\n }\n\n if (\"raw\" in token) {\n return token.raw;\n }\n\n return \"\";\n};\n\nconst parseMarkdownContent = (rawContent: string) => {\n const { content: matterContent, data: matterData } = matter(rawContent);\n const tokens = lexer(matterContent.trim());\n\n let title = matterData.title || \"\";\n let description = matterData.description || \"\";\n const plainTextParts: string[] = [];\n\n const headings: string[] = [];\n tokens.forEach((token: Token) => {\n if (token.type === \"heading\") {\n const headingText = parseTokenText(token);\n if (headingText) {\n if (!title) title = headingText;\n headings.push(headingText);\n plainTextParts.push(headingText);\n }\n return;\n }\n if (token.type === \"paragraph\") {\n const paragraphText = parseTokenText(token);\n if (paragraphText) {\n if (!description) description = paragraphText;\n plainTextParts.push(paragraphText);\n }\n return;\n }\n if ([\"list\", \"blockquote\", \"table\"].includes(token.type)) {\n plainTextParts.push(parseTokenText(token));\n return;\n }\n });\n\n return {\n title,\n description,\n headings: headings.join(\" \").trim(),\n plainText: plainTextParts.join(\" \").trim(),\n };\n};\n\n/**\n * Generates a static search index from all documentation pages.\n * Processes markdown content and creates a MiniSearch index file.\n *\n * @example\n * ```ts\n * import { generateSearchIndex } from \"@robindoc/minisearch\";\n * import { getStaticParams, getPageData } from \"./robindoc\";\n *\n * await generateSearchIndex(\n * getStaticParams,\n * getPageData,\n * \"./public/search-index.json\"\n * );\n * ```\n *\n * @see {@link https://robindoc.com/docs/customization/search Search integration}\n */\nexport const generateSearchIndex = async (\n getStaticParams: GetStaticParamsFunction,\n getPageData: GetPageDataFunction,\n outputPath: string,\n): Promise<void> => {\n const searchItems: SearchIndexItem[] = [];\n\n const staticParams = await getStaticParams();\n\n for (const staticParam of staticParams) {\n const pathname = `/${staticParam.segments.join(\"/\")}`;\n try {\n const pageData = await getPageData(pathname);\n\n if (!pageData) continue;\n\n const parsed = parseMarkdownContent(pageData.raw);\n const title = pageData.title || parsed.title;\n const description = parsed.description || parsed.plainText.substring(0, 200).trim();\n\n searchItems.push({\n id: pathname,\n title,\n href: pathname,\n headings: parsed.headings,\n content: parsed.plainText,\n description,\n });\n } catch (error) {\n console.warn(`Failed to index page ${pathname}:`, error);\n }\n }\n\n const searchIndex = new MiniSearch<SearchIndexItem>({\n fields: [\"title\", \"content\", \"headings\", \"description\"],\n storeFields: [\"id\", \"title\", \"href\", \"headings\", \"description\"],\n searchOptions: {\n boost: { title: 5, headings: 3, description: 2 },\n fuzzy: 0.2,\n },\n });\n\n await Promise.all([searchIndex.addAllAsync(searchItems), mkdir(dirname(outputPath), { recursive: true })]);\n await writeFile(outputPath, JSON.stringify(searchIndex.toJSON()), \"utf-8\");\n};\n"],"names":["parseTokenText","token","tokens","map","el","join","text","raw","parseMarkdownContent","rawContent","content","matterContent","data","matterData","matter","lexer","trim","title","description","plainTextParts","headings","forEach","type","headingText","push","paragraphText","includes","plainText","generateSearchIndex","async","getStaticParams","getPageData","outputPath","searchItems","staticParams","staticParam","pathname","segments","pageData","parsed","substring","id","href","error","console","warn","searchIndex","MiniSearch","fields","storeFields","searchOptions","boost","fuzzy","Promise","all","addAllAsync","mkdir","dirname","recursive","writeFile","JSON","stringify","toJSON"],"mappings":"sKAQA,MAAMA,EAAkBC,GACfA,EAED,WAAYA,EACLA,EAAMC,QAAQC,IAAKC,GAAcJ,EAAeI,IAAKC,KAAK,KAAO,GAGxE,SAAUJ,EACHA,EAAMK,KAGb,QAASL,EACFA,EAAMM,IAGV,GAdY,GAiBjBC,EAAwBC,IAC1B,MAAQC,QAASC,EAAeC,KAAMC,GAAeC,EAAOL,GACtDP,EAASa,EAAMJ,EAAcK,QAEnC,IAAIC,EAAQJ,EAAWI,OAAS,GAC5BC,EAAcL,EAAWK,aAAe,GAC5C,MAAMC,EAA2B,GAE3BC,EAAqB,GAyB3B,OAxBAlB,EAAOmB,QAASpB,IACZ,GAAmB,YAAfA,EAAMqB,KAAoB,CAC1B,MAAMC,EAAcvB,EAAeC,GAMnC,YALIsB,IACKN,IAAOA,EAAQM,GACpBH,EAASI,KAAKD,GACdJ,EAAeK,KAAKD,IAG5B,CACA,GAAmB,cAAftB,EAAMqB,KAAsB,CAC5B,MAAMG,EAAgBzB,EAAeC,GAKrC,YAJIwB,IACKP,IAAaA,EAAcO,GAChCN,EAAeK,KAAKC,IAG5B,CACI,CAAC,OAAQ,aAAc,SAASC,SAASzB,EAAMqB,OAC/CH,EAAeK,KAAKxB,EAAeC,MAKpC,CACHgB,QACAC,cACAE,SAAUA,EAASf,KAAK,KAAKW,OAC7BW,UAAWR,EAAed,KAAK,KAAKW,SAsB/BY,EAAsBC,MAC/BC,EACAC,EACAC,KAEA,MAAMC,EAAiC,GAEjCC,QAAqBJ,IAE3B,IAAK,MAAMK,KAAeD,EAAc,CACpC,MAAME,EAAW,IAAID,EAAYE,SAAShC,KAAK,OAC/C,IACI,MAAMiC,QAAiBP,EAAYK,GAEnC,IAAKE,EAAU,SAEf,MAAMC,EAAS/B,EAAqB8B,EAAS/B,KACvCU,EAAQqB,EAASrB,OAASsB,EAAOtB,MACjCC,EAAcqB,EAAOrB,aAAeqB,EAAOZ,UAAUa,UAAU,EAAG,KAAKxB,OAE7EiB,EAAYT,KAAK,CACbiB,GAAIL,EACJnB,QACAyB,KAAMN,EACNhB,SAAUmB,EAAOnB,SACjBV,QAAS6B,EAAOZ,UAChBT,eAER,CAAE,MAAOyB,GACLC,QAAQC,KAAK,wBAAwBT,KAAaO,EACtD,CACJ,CAEA,MAAMG,EAAc,IAAIC,EAA4B,CAChDC,OAAQ,CAAC,QAAS,UAAW,WAAY,eACzCC,YAAa,CAAC,KAAM,QAAS,OAAQ,WAAY,eACjDC,cAAe,CACXC,MAAO,CAAElC,MAAO,EAAGG,SAAU,EAAGF,YAAa,GAC7CkC,MAAO,YAITC,QAAQC,IAAI,CAACR,EAAYS,YAAYtB,GAAcuB,EAAMC,EAAQzB,GAAa,CAAE0B,WAAW,YAC3FC,EAAU3B,EAAY4B,KAAKC,UAAUf,EAAYgB,UAAW"}
package/lib/provider.d.ts CHANGED
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Alias for createStaticSearcher, exported as provider for convenience.
3
+ * Creates a searcher function that loads and queries a static search index.
4
+ *
5
+ * @see {@link https://robindoc.com/docs/customization/search Search integration}
6
+ */
1
7
  export declare const createSearchProvider: (indexUrl: string) => import("./types").Searcher;
2
8
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,kDAAuB,CAAC"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,kDAAuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sources":["../src/provider.ts"],"sourcesContent":["import { createStaticSearcher } from \"./create-static-searcher\";\n\nexport const createSearchProvider = createStaticSearcher;\n"],"names":["createSearchProvider","createStaticSearcher"],"mappings":"mEAEO,MAAMA,EAAuBC"}
1
+ {"version":3,"file":"provider.js","sources":["../src/provider.ts"],"sourcesContent":["import { createStaticSearcher } from \"./create-static-searcher\";\n\n/**\n * Alias for createStaticSearcher, exported as provider for convenience.\n * Creates a searcher function that loads and queries a static search index.\n *\n * @see {@link https://robindoc.com/docs/customization/search Search integration}\n */\nexport const createSearchProvider = createStaticSearcher;\n"],"names":["createSearchProvider","createStaticSearcher"],"mappings":"mEAQO,MAAMA,EAAuBC"}
package/lib/types.d.ts CHANGED
@@ -1,10 +1,24 @@
1
+ /**
2
+ * Search result item returned by searcher functions.
3
+ */
1
4
  export type SearchItem = {
2
5
  title: string;
3
6
  href: string;
4
7
  description?: string;
5
8
  };
9
+ /**
10
+ * Array of search results.
11
+ */
6
12
  export type SearchResults = SearchItem[];
13
+ /**
14
+ * Search function signature for Robindoc search integration.
15
+ * Must be cancellable via AbortController.
16
+ */
7
17
  export type Searcher = (search: string, abortController: AbortController) => Promise<SearchItem[]>;
18
+ /**
19
+ * Internal search index item structure.
20
+ * Used when generating and loading search indices.
21
+ */
8
22
  export type SearchIndexItem = {
9
23
  id: string;
10
24
  title: string;
@@ -13,9 +27,16 @@ export type SearchIndexItem = {
13
27
  content: string;
14
28
  href: string;
15
29
  };
30
+ /**
31
+ * Function type for retrieving static page parameters.
32
+ */
16
33
  export type GetStaticParamsFunction = () => Promise<Array<{
17
34
  segments: string[];
18
35
  }>>;
36
+ /**
37
+ * Function type for retrieving page data.
38
+ * Returns page title and raw markdown content.
39
+ */
19
40
  export type GetPageDataFunction = (pathname: string) => Promise<{
20
41
  title: string;
21
42
  raw: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,G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GG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC,CAAC;AAEnF;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robindoc/minisearch",
3
- "version": "3.6.4",
3
+ "version": "3.7.0",
4
4
  "description": "MiniSearch integration for robindoc documentation sites",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {