Skip to content

search.ts#

View Markdown

Source

8 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

8 symbols 7 functions 1 modules 17 parameters 7 returns

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>

View source

Parameters

  • srcDir string
  • base string
  • extensions readonly string[]

    optional · default: DEFAULTMARKDOWNEXTENSIONS

  • publishState ResolvedPublishStateOptions

    optional

  • excludeDocumentIds readonly string[]

    optional · default: []

  • mdx boolean

    optional

  • conditionalBlocks ResolvedConditionalBlockOptions

    optional

  • citations ResolvedCitationsOptions

    optional

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): string

View source

Parameters

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[]

View source

Parameters

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[]): boolean

View source

Parameters

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): ScopedSearchQuery

View source

Parameters

  • query string

Returns

ScopedSearchQuery
fnresolveSearchOptions(options: SearchOptions | boolean | undefined): ResolvedSearchOptionsResolves search options with defaults.

Resolves search options with defaults.

Signature

export function resolveSearchOptions(options: SearchOptions | boolean | undefined): ResolvedSearchOptions

View source

Parameters

Returns

ResolvedSearchOptions
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.

View source

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>

View source

Parameters

  • indexJson string
  • outDir string

Returns

Promise<void>