UNPKG

@barnabask/astro-minisearch

Version:

Utilities to add a static full text index to an Astro project

66 lines (65 loc) 2.12 kB
import { Options as MiniSearchOptions } from "minisearch"; import { z } from "zod"; declare const globResultValidator: z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodPromise<z.ZodAny>>>; export type GlobResult = z.infer<typeof globResultValidator>; export type PluginOptions = z.infer<typeof pluginOptionValidator>; /** Plugin options [Zod](https://zod.dev/) schema */ export declare const pluginOptionValidator: z.ZodObject<{ /** * Frontmatter property to store plain text output * @default "plainText". */ contentKey: z.ZodDefault<z.ZodString>; /** * Strip emoji out of text * @default true */ removeEmoji: z.ZodDefault<z.ZodBoolean>; /** * Tags to consider headings and make separate search documents. * @default ["h2", "h3"] */ headingTags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { contentKey: string; removeEmoji: boolean; headingTags: string[]; }, { contentKey?: string | undefined; removeEmoji?: boolean | undefined; headingTags?: string[] | undefined; }>; /** @see [MiniSearch API](https://lucaong.github.io/minisearch/modules/_minisearch_.html#searchoptions-1) */ export type SearchIndexOptions = MiniSearchOptions<SearchDocument>; /** * Represents a search document that will be given to the indexer. * Although called "document", it's more of the content for one destination. * For example, it may only the single section of a document. */ export type SearchDocument = { url?: string; heading?: string; title: string; text: string; }; /** Internal type for assembling document sections */ export type Section = { heading: string; text: string; }; /** * ContentEntry class to match the one in "astro:content", * which we can't access outside of an Astro project. */ export type ContentEntry = { slug: string; render: () => Promise<{ headings: { depth: number; slug: string; text: string; }[]; remarkPluginFrontmatter: Record<string, any>; }>; }; export {};