# plugins

/docs/.vuepress/config/plugin.js

# 搜索

此插件默认包含在主题中

# 使用

  1. 启用此插件
// .vuepress/config/plugins.js
module.exports = [
  [
    '@vuepress/search',
    {
      searchMaxSuggestions: 10,
    },
  ],
]

2.本插件将自动注入指向搜索组件的 webpack 别名 @SearchBox,以便您可以直接在 layout 组件中使用它:

<template>
  <div class="foo-layout">
    <header>
      <SearchBox />
    </header>
    <main>
      ...
    </main>
  </div>
</template>

<script>
import SearchBox from '@SearchBox'

export default {
  components: { SearchBox },
}
</script>

# 选项

# searchMaxSuggestions

设置搜索的最大结果数

  • 类型: number
  • 默认值: 5


# test

设置搜索匹配条件

  • 类型: RegExp | Array<RegExp>
  • 默认值: null

例如目录结构如下:

docs/
├── .vuepress/
│    └── ...
│
├── master/
│    └── ...
│
├── 1.0/
│    └── ...
│
└── 2.0/
     └── ...

可以设置test如下:

module.exports = [
  [
    '@vuepress/search',
    {
      searchMaxSuggestions: 10,
      test: '/1.0/', // or ['/1\.0/', '/2\.0/']
    },
  ],
]


# searchHotkeys

配置热键,按下热键将聚焦搜索框。设置为空数组以禁用此功能

  • 类型: Array<string>
  • 默认值: ['s', '/']

Copyright 2005-2019 Tencent Smart Retail All Right Reserved.