UNPKG

gatsby-plugin-local-search

Version:

Gatsby plugin for providing client-side search for data available in Gatsby's GraphQL layer using a variety of engines

42 lines (33 loc) 932 B
import { PluginOptions as GatsbyPluginOptions, NodeInput, Node } from 'gatsby' import { CreateOptions as FlexSearchCreateOptions } from 'flexsearch' export interface PartialContext { nodeModel: { getNodeById: (input: { id: string; type?: string }) => Node } } export type IndexableDocument = Record<string, unknown> export type Store = Record<string, unknown> export enum NodeType { LocalSearch = 'LocalSearch', } export type Engine = 'flexsearch' | 'lunr' export interface LocalSearchNodeInput extends NodeInput { name: string engine: Engine index: string store: Store } interface NormalizerInput { errors?: unknown data?: unknown } export interface PluginOptions extends GatsbyPluginOptions { name: string engine: Engine engineOptions?: FlexSearchCreateOptions ref?: string index?: string[] store?: string[] query: string normalizer: (input: NormalizerInput) => IndexableDocument[] }