From b0e32093103ca08dbf1622a3fecefb2e82a10d2c Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Mon, 24 Sep 2018 01:16:13 +0800 Subject: [PATCH] feat: plugin-search --- packages/@vuepress/plugin-search/.npmignore | 2 + packages/@vuepress/plugin-search/README.md | 42 +++++++++++++++++++ .../SearchBox.vue | 5 ++- packages/@vuepress/plugin-search/index.js | 11 +++++ packages/@vuepress/plugin-search/package.json | 25 +++++++++++ .../components => plugin-search}/search.svg | 0 .../theme-default/components/Navbar.vue | 2 +- 7 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 packages/@vuepress/plugin-search/.npmignore create mode 100644 packages/@vuepress/plugin-search/README.md rename packages/@vuepress/{theme-default/components => plugin-search}/SearchBox.vue (97%) create mode 100644 packages/@vuepress/plugin-search/index.js create mode 100644 packages/@vuepress/plugin-search/package.json rename packages/@vuepress/{theme-default/components => plugin-search}/search.svg (100%) diff --git a/packages/@vuepress/plugin-search/.npmignore b/packages/@vuepress/plugin-search/.npmignore new file mode 100644 index 00000000..18f0a334 --- /dev/null +++ b/packages/@vuepress/plugin-search/.npmignore @@ -0,0 +1,2 @@ +__tests__ +__mocks__ \ No newline at end of file diff --git a/packages/@vuepress/plugin-search/README.md b/packages/@vuepress/plugin-search/README.md new file mode 100644 index 00000000..98f77fcf --- /dev/null +++ b/packages/@vuepress/plugin-search/README.md @@ -0,0 +1,42 @@ +# @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 diff --git a/packages/@vuepress/theme-default/components/SearchBox.vue b/packages/@vuepress/plugin-search/SearchBox.vue similarity index 97% rename from packages/@vuepress/theme-default/components/SearchBox.vue rename to packages/@vuepress/plugin-search/SearchBox.vue index abaedf1c..76016dd9 100644 --- a/packages/@vuepress/theme-default/components/SearchBox.vue +++ b/packages/@vuepress/plugin-search/SearchBox.vue @@ -36,6 +36,7 @@