fumadocs-core
Version:
The React.js library for building a documentation website
51 lines • 2 kB
TypeScript
import { m as SharedIndex, n as SearchAPI, t as QueryOptions } from "../server-CYiYlUy_.js";
import { D as LoaderOutput, T as LoaderConfig } from "../index-Dyo_baWl.js";
import { t as Awaitable } from "../types-Dvkw0Kd0.js";
import { n as I18nConfig } from "../index-DFrWGSeW.js";
import "../index-BlFx9iJj.js";
import { DocumentData, DocumentOptions } from "flexsearch";
interface SharedDocument {
id: string;
content: string;
page_id: string;
type: 'page' | 'heading' | 'text';
breadcrumbs?: string[];
tags: string[];
url: string;
locale?: string;
table?: string;
}
type Doc = SharedDocument & DocumentData;
export type Index = SharedIndex;
export interface IndexWithLocale extends Index {
locale: string;
}
export interface Options {
indexes: Index[] | (() => Awaitable<Index[]>);
document?: DocumentOptions<Doc>;
}
export type ExportedData = {
type: 'default';
raw: Record<string, string>;
} | {
type: 'i18n';
raw: Record<string, Record<string, string>>;
};
export interface I18nOptions extends Omit<Options, 'indexes'> {
i18n: I18nConfig;
indexes: IndexWithLocale[] | (() => Awaitable<IndexWithLocale[]>);
/**
* options for each locale, see https://github.com/nextapps-de/flexsearch/blob/master/doc/encoder.md.
*/
localeMap?: Record<string, Partial<DocumentOptions<Doc>> | 'cjk'>;
}
export declare function flexsearch(options: Options): SearchAPI;
export declare function flexsearchI18n(options: I18nOptions): SearchAPI;
export interface FromSourceOptions<C extends LoaderConfig> extends Pick<I18nOptions, 'localeMap' | 'document'> {
buildIndex?: (page: C['page']) => Awaitable<Index>;
}
/**
* create server from loader, if passed as function, the server will re-index all records once a different instance of loader is returned.
*/
export declare function flexsearchFromSource<C extends LoaderConfig>(loader: LoaderOutput<C> | (() => Awaitable<LoaderOutput<C>>), options?: FromSourceOptions<NoInfer<C>>): SearchAPI<QueryOptions>;
export {};