search.ts#
8 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference#
fnbuildSearchIndex(srcDir: string, base: string, extensions: readonly string[] = DEFAULT_MARKDOWN_EXTENSIONS, publishState?: ResolvedPublishStateOptions, excludeDocumentIds: readonly string[] = [], mdx?: boolean, conditionalBlocks?: ResolvedConditionalBlockOptions, citations?: ResolvedCitationsOptions): Promise<string>Builds the search index from Markdown files. publishState is forwarded to the n…
Builds the search index from Markdown files.
publishState is forwarded to the native indexer. excludeDocumentIds then drops matching documents and rebuilds the BM25 index so omitted pages (such as the opt-in 404 source) are not searchable.
Signature
export async function buildSearchIndex(srcDir: string, base: string, extensions: readonly string[] = DEFAULT_MARKDOWN_EXTENSIONS, publishState?: ResolvedPublishStateOptions, excludeDocumentIds: readonly string[] = [], mdx?: boolean, conditionalBlocks?: ResolvedConditionalBlockOptions, citations?: ResolvedCitationsOptions): Promise<string>Parameters
-
srcDirstring -
basestring -
extensionsreadonly string[]optional · default: DEFAULTMARKDOWNEXTENSIONS
-
publishStateResolvedPublishStateOptionsoptional
-
excludeDocumentIdsreadonly string[]optional · default: []
-
mdxbooleanoptional
-
conditionalBlocksResolvedConditionalBlockOptionsoptional
-
citationsResolvedCitationsOptionsoptional
Returns
Promise<string>
fngenerateSearchModule(options: ResolvedSearchOptions, indexPath: string): stringClient-side search module code. This is injected into the bundle as a virtual m…
Client-side search module code. This is injected into the bundle as a virtual module.
Signature
export function generateSearchModule(options: ResolvedSearchOptions, indexPath: string): stringParameters
-
optionsResolvedSearchOptions -
indexPathstring
Returns
string
fngetSearchDocumentScopes(doc: Pick<SearchDocument, "id" | "url">): string[]Derives hierarchical search scopes from a document id or URL. For example, api/…
Derives hierarchical search scopes from a document id or URL.
For example, api/math/index yields ["api", "api/math"].
Signature
export function getSearchDocumentScopes(doc: Pick<SearchDocument, "id" | "url">): string[]Parameters
-
docPick<SearchDocument, "id" | "url">
Returns
string[]
fnmatchesSearchScopes(doc: Pick<SearchDocument, "id" | "url">, scopes: string[]): booleanReturns true when a search document belongs to at least one requested scope.
Returns true when a search document belongs to at least one requested scope.
Signature
export function matchesSearchScopes(doc: Pick<SearchDocument, "id" | "url">, scopes: string[]): booleanParameters
-
docPick<SearchDocument, "id" | "url"> -
scopesstring[]
Returns
boolean
fnparseScopedSearchQuery(query: string): ScopedSearchQuerySplits a raw query into free-text terms and @scope prefixes.
Splits a raw query into free-text terms and @scope prefixes.
Signature
export function parseScopedSearchQuery(query: string): ScopedSearchQueryParameters
-
querystring
Returns
fnresolveSearchOptions(options: SearchOptions | boolean | undefined): ResolvedSearchOptionsResolves search options with defaults.
Resolves search options with defaults.
Signature
export function resolveSearchOptions(options: SearchOptions | boolean | undefined): ResolvedSearchOptionsParameters
-
optionsSearchOptions | boolean | undefined
Returns
modulesearchFull-text search functionality for Ox Content. Generates search index at build time and provides client-side search.
Full-text search functionality for Ox Content.
Generates search index at build time and provides client-side search.
fnwriteSearchIndex(indexJson: string, outDir: string): Promise<void>Writes the search index to a file.
Writes the search index to a file.
Signature
export async function writeSearchIndex(indexJson: string, outDir: string): Promise<void>Parameters
-
indexJsonstring -
outDirstring
Returns
Promise<void>