diff --git a/docs/reference/default-theme-search.md b/docs/reference/default-theme-search.md index 6f5925ca..13f5ded0 100644 --- a/docs/reference/default-theme-search.md +++ b/docs/reference/default-theme-search.md @@ -1,3 +1,7 @@ +--- +outline: deep +--- + # Search ## Local Search @@ -58,6 +62,38 @@ export default defineConfig({ }) ``` +### miniSearch options + +You can configure MiniSearch like this: + +```ts +import { defineConfig } from 'vitepress' + +export default defineConfig({ + themeConfig: { + search: { + provider: 'local', + options: { + miniSearch: { + /** + * @type {Pick} + */ + options: { /* ... */ }, + /** + * @type {import('minisearch').SearchOptions} + * @default + * { fuzzy: 0.2, prefix: true, boost: { title: 4, text: 2, titles: 1 } } + */ + searchOptions: { /* ... */ } + } + } + } + } +}) +``` + +Learn more in [MiniSearch docs](https://lucaong.github.io/minisearch/classes/_minisearch_.minisearch.html). + ## Algolia Search VitePress supports searching your docs site using [Algolia DocSearch](https://docsearch.algolia.com/docs/what-is-docsearch). Refer their getting started guide. In your `.vitepress/config.ts` you'll need to provide at least the following to make it work: diff --git a/src/client/theme-default/components/VPLocalSearchBox.vue b/src/client/theme-default/components/VPLocalSearchBox.vue index 5614e336..0e1eddac 100644 --- a/src/client/theme-default/components/VPLocalSearchBox.vue +++ b/src/client/theme-default/components/VPLocalSearchBox.vue @@ -80,8 +80,12 @@ const searchIndex = computedAsync(async () => searchOptions: { fuzzy: 0.2, prefix: true, - boost: { title: 4, text: 2, titles: 1 } - } + boost: { title: 4, text: 2, titles: 1 }, + ...(theme.value.search?.provider === 'local' && + theme.value.search.options?.miniSearch?.searchOptions) + }, + ...(theme.value.search?.provider === 'local' && + theme.value.search.options?.miniSearch?.options) } ) ) @@ -396,8 +400,16 @@ function formMarkRegex(terms: Set) {
-