提交 b0e32093 编写于 作者: U ULIVZ

feat: plugin-search

上级 7b42984f
__tests__
__mocks__
\ No newline at end of file
# @vuepress/plugin-search
> header-based search plugin for vuepress
## Usage
1. Enable this plugin:
```js
// .vuepress/config.js or themedir/index.js
module.exports = {
plugins: [
['@vuepress/search', {
searchMaxSuggestions: 10
}]
],
// Tweak the default color via palette.
palette: {
$accentColor: '#b58900',
$textColor: '#586e75',
$borderColor: '#eaecef',
$codeBgColor: '#282c34',
$arrowBgColor: '#ccc'
}
}
```
2. Using search component:
```vue
import SearchBox from '@SearchBox'
```
## Options
### searchMaxSuggestions
- Type: `number`
- Default: `true`
Set the maximum number of results for search
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
</template> </template>
<script> <script>
/* global SEARCH_MAX_SUGGESTIONS */
export default { export default {
data () { data () {
return { return {
...@@ -60,8 +61,8 @@ export default { ...@@ -60,8 +61,8 @@ export default {
return return
} }
const { pages, themeConfig } = this.$site const { pages } = this.$site
const max = themeConfig.searchMaxSuggestions || 5 const max = SEARCH_MAX_SUGGESTIONS
const localePath = this.$localePath const localePath = this.$localePath
const matches = item => ( const matches = item => (
item.title && item.title &&
......
const path = require('path')
module.exports = (options) => ({
alias: {
'@SearchBox':
path.resolve(__dirname, 'SearchBox.vue')
},
define: {
SEARCH_MAX_SUGGESTIONS: options.searchMaxSuggestions || 5
}
})
{
"name": "@vuepress/plugin-search",
"version": "1.0.0",
"description": "search plugin for vuepress",
"main": "index.js",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vuepress.git"
},
"keywords": [
"documentation",
"vue",
"vuepress",
"generator"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/vuepress/issues"
},
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/plugin-search#readme"
}
\ No newline at end of file
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<script> <script>
import SidebarButton from './SidebarButton.vue' import SidebarButton from './SidebarButton.vue'
import AlgoliaSearchBox from '@AlgoliaSearchBox' import AlgoliaSearchBox from '@AlgoliaSearchBox'
import SearchBox from './SearchBox.vue' import SearchBox from '@SearchBox'
import NavLinks from './NavLinks.vue' import NavLinks from './NavLinks.vue'
export default { export default {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册