Plugin Options

About 2 min

indexContent

  • Type: boolean
  • Default: false

Whether to enable content indexing.

Tips

By default only headings and excerpt of the page will be indexed along with your cutom fields, and the content of the page will not be indexed. If you need to index the content of the page, you can set this option to true

customFields

  • Type: SearchProCustomFieldOptions[]

    interface SearchProCustomFieldOptions {
      /**
       * Custom field getter
       */
      getter: (page: Page) => string | string[] | null;
    
      /**
       * Display content
       *
       * @description `$content` will be replaced by the content returned by `getter`
       *
       * @default `$content`
       */
      formatter?: string | Record<string, string>;
    }
    
  • Required: No

Custom search items.

Example

Assuming your theme uses category and tag tags in Frontmatter to mark categories and tags of articles, you can use the following configuration:

import { defineUserConfig } from "vuepress";
import { searchProPlugin } from "vuepress-plugin-search-pro";

export default defineUserConfig({
  // We assume you are using the following multilingual
  locales: {
    "/": {
      lang: "en-US",
    },
    "/zh/": {
      lang: "zh-CN",
    },
  },

  plugins: [
    searchProPlugin({
      customFields: [
        {
          getter: (page) => page.frontmatter.category,
          formatter: {
            "/": "Category: $content",
            "/zh/": "分类:$content",
          },
        },
        {
          getter: (page) => page.frontmatter.tag,
          formatter: {
            "/": "Tag: $content",
            "/zh/": "标签:$content",
          },
        },
      ],
    }),
  ],
});

hotKeys

  • Type: SearchProHotKeyOptions[]

    interface SearchProHotKeyOptions {
      /**
       * Value of `event.key` to trigger the hot key
       */
      key: string;
    
      /**
       * Whether to press `event.altKey` at the same time
       *
       * @default false
       */
      alt?: boolean;
    
      /**
       * Whether to press `event.ctrlKey` at the same time
       *
       * @default false
       */
      ctrl?: boolean;
    
      /**
       * Whether to press `event.shiftKey` at the same time
       *
       * @default false
       */
      shift?: boolean;
    }
    
  • Default: [{key: 'k', ctrl: true}]

Specify the event.keyopen in new window of the hotkeys.

When hotkeys are pressed, the search box input will be focused. Set to an empty array to disable hotkeys.

historyCount

  • Type: number
  • Default: 5

Max stored history item count.

delay

  • Type: number
  • Default: 300

Delay to start searching after input.

Note

Performing client search with huge contents could be slow, so under this case you might need to increase this value to ensure user finish input before searching.

hotReload

  • Type: boolean
  • Default: Whether using --debug flag

Whether to enable hot reload in the development server.

Note

It is disabled by default because this feature can have a huge performance impact on sites with huge content and drastically increases the speed of hot reloads when editing Markdown.

Usually in development, users do not need to update the index database in real time.

locales

  • Type: SearchProLocaleConfig

    /**
     * Multi language config for `vuepress-plugin-search-pro` plugin
     */
    interface SearchProLocaleData {
      /**
       * Search box placeholder text
       */
      placeholder: string;
    
      /**
       * Search text
       */
      search: string;
    
      /**
       * Close text
       */
      close: string;
    
      /**
       * Select hint
       */
      select: string;
    
      /**
       * Choose hint
       */
      navigate: string;
    
      /**
       * Close hint
       */
      exit: string;
    
      /**
       * Loading hint
       */
      loading: string;
    
      /**
       * Empty hint
       */
      empty: string;
    }
    
    interface SearchProLocaleConfig {
      [localePath: string]: SearchProLocaleData;
    }
    
  • Required: No

Multilingual configuration of the search plugin.

Built-in Supported Languages
  • Simplified Chinese (zh-CN)
  • Traditional Chinese (zh-TW)
  • English (United States) (en-US)
  • German (de-DE)
  • German (Australia) (de-AT)
  • Russian (ru-RU)
  • Ukrainian (uk-UA)
  • Vietnamese (vi-VN)
  • Portuguese (Brazil) (pt-BR)
  • Polish (pl-PL)
  • French (fr-FR)
  • Spanish (es-ES)
  • Slovak (sk-SK)
  • Japanese (ja-JP)
  • Turkish (tr-TR)
  • Korean (ko-KR)
  • Finnish (fi-FI)