VuePress plugin for FlexSearch.
To integrate VuePress and FlexSearch, firstly I have learned the basics from below packages:
Unlike these packages, to focus on search for Japanese, this plugin is using kuromoji (Japanese morphological analyzer) via kuromojin.
Search data is created after applying n-gram to texts extracted by kuromoji. And so search query is also preprocessed by n-gram.
.vuepress/config.js
module.exports = {
plugins: [
['@smori1983/vuepress-plugin-flexsearch', {
//searchHotKeys: ['s', '/'],
//searchMaxSuggestions: 20,
//searchPaths: null,
//uiAlignRightFactor: 10,
//excerptAroundLength: 100,
//excerptHeadText: '... ',
//excerptTailText: ' ...',
//tokenizerType: 'kuromoji.default',
//ngramSize: 3,
}],
],
};
Some configs are same as default @vuepress/plugin-search
.
- Type:
string[]
- Default:
['s', '/']
Set to an empty array to disable this feature.
- Type:
number
- Default:
20
The maximum number of results for search.
- Type:
RegExp
|RegExp[]
- Default:
null
Configure if you want to limit the searchable paths.
- Type:
number
- Default:
10
Condition to add class attribute of align-light
to suggestions area, which will be added when the number of navbar menus is less than uiAlignRightFactor
.
- Type:
number
- Default:
100
Define how many texts are shown around first matched text on the excerpt of the result.
- Type:
string
- Default:
'... '
Define text which is shown for abbreviation if preceding text is longer than excerptAroundLength
on the excerpt of the result.
- Type:
string
- Default:
' ...'
Define text which is shown for abbreviation if succeeding text is longer than excerptAroundLength
on the excerpt of the result.
- Type:
string
- Default:
'kuromoji.default'
- Type:
number
- Default:
3
Provides search form you can set up on arbitrary markdown file.
Usage example:
# Search
<PluginFlexSearchForm/>
If env variable VUEPRESS_FLEXSEARCH
is defined as disabled
, the plugin does not create search data on ready()
callback.
It will be helpful if there are too many pages and so it takes long time to launch.
Example:
{
"scripts": {
"dev": "vuepress dev docs",
"dev:light": "VUEPRESS_FLEXSEARCH=disabled vuepress dev docs",
"build": "vuepress build docs"
}
}
For Windows, you can configure with cross-env:
{
"scripts": {
"dev": "vuepress dev docs",
"dev:light": "cross-env VUEPRESS_FLEXSEARCH=disabled vuepress dev docs",
"build": "vuepress build docs"
}
}