Skip to content

Commit 8d1621c

Browse files
committed
update flexsearch plugin
1 parent 385a8f9 commit 8d1621c

File tree

14 files changed

+695
-7956
lines changed

14 files changed

+695
-7956
lines changed

.vuepress/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ module.exports = {
9797
//filter:"",
9898
count: "20",
9999
}],
100-
// 全文搜索 https://github.com/bajins/vuepress-plugin-flexsearch-plus
101-
['flexsearch-plus'],
100+
// 全文搜索
101+
[require('./plugins/vuepress-plugin-flexsearch/index.js')],
102+
// ['fulltext-search'],
102103
// https://github.com/znicholasbrown/vuepress-plugin-code-copy
103104
["vuepress-plugin-code-copy", true],
104105
// https://github.com/ekoeryanto/vuepress-plugin-sitemap
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '17 10 * * 5'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'javascript' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[![https://badgen.net/npm/v/vuepress-plugin-flexsearch](https://badgen.net/npm/v/vuepress-plugin-flexsearch)](https://www.npmjs.com/package/vuepress-plugin-flexsearch)
2+
[![https://badgen.net/npm/dt/vuepress-plugin-flexsearch](https://badgen.net/npm/dt/vuepress-plugin-flexsearch)](https://www.npmjs.com/package/vuepress-plugin-flexsearch)
3+
[![https://badgen.net/npm/license/vuepress-plugin-flexsearch](https://badgen.net/npm/license/vuepress-plugin-flexsearch)](https://github.com/z3by/vuepress-plugin-flexsearch/blob/master/LICENSE)
4+
[![https://badgen.net/github/contributors/z3by/vuepress-plugin-flexsearch](https://badgen.net/github/contributors/z3by/vuepress-plugin-flexsearch)](https://github.com/z3by/vuepress-plugin-flexsearch/graphs/contributors)
5+
6+
# vuepress-plugin-flexsearch
7+
8+
Next-Generation full text search library for Vuepress
9+
10+
> A great replacement of the default Vuepress search plugin.
11+
12+
## Installation
13+
14+
```bash
15+
yarn add -D vuepress-plugin-flexsearch-plus
16+
// or npm install vuepress-plugin-flexsearch-plus -D
17+
18+
```
19+
20+
## Usage
21+
22+
Use the default settings:
23+
24+
```js
25+
// .vuepress/config.js
26+
27+
module.exports = {
28+
plugins: [
29+
['flexsearch'],
30+
// other plugins
31+
]
32+
}
33+
```
34+
35+
Or modify the settings to match your needs:
36+
37+
```js
38+
// .vuepress/config.js
39+
40+
module.exports = {
41+
plugins: [
42+
['flexsearch', {
43+
/*
44+
Plugin custom options
45+
*/
46+
maxSuggestions: 10, // how many search suggestions to show on the menu, the default is 10.
47+
searchPaths: ['path1', 'path2'], // an array of paths to search in, keep it null to search all docs.
48+
searchHotkeys: ['s'], // Hot keys to activate the search input, the default is "s" but you can add more.
49+
searchResultLength: 60, // the length of the suggestion result text by characters, the default is 60 characters.
50+
/*
51+
Default FlexSearch options
52+
To override the default options you can see available options at https://github.com/nextapps-de/flexsearch
53+
*/
54+
search_options: {
55+
encode: "icase",
56+
tokenize: "forward",
57+
resolution: 9,
58+
doc: {
59+
id: "key",
60+
field: ["title", "content", "headers"],
61+
}
62+
}
63+
}],
64+
// other plugins
65+
]
66+
}
67+
```
68+
69+
## Credit
70+
71+
Thanks to [nextapps-de/flexsearch](https://github.com/nextapps-de/flexsearch)
72+
73+
## Contributions
74+
75+
PRs are welcome :heart:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# example
2+
3+
>
4+
5+
## Development
6+
7+
```bash
8+
yarn dev
9+
yarn build
10+
```
11+
12+
For more details, please head VuePress's [documentation](https://v1.vuepress.vuejs.org/).
13+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "example",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "index.js",
6+
"authors": {
7+
"name": "z3by",
8+
"email": "[email protected]"
9+
},
10+
"repository": "/example",
11+
"scripts": {
12+
"dev": "vuepress dev docs",
13+
"build": "vuepress build docs"
14+
},
15+
"license": "MIT",
16+
"devDependencies": {
17+
"@vuepress/plugin-back-to-top": "^1.0.0",
18+
"@vuepress/plugin-medium-zoom": "^1.0.0",
19+
"vuepress": "1.8.2"
20+
},
21+
"dependencies": {
22+
}
23+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const { path } = require("@vuepress/shared-utils");
2+
const { getPageText } = require("./src/utils");
3+
4+
let defaultSearchOptions = {
5+
encode: "icase",
6+
tokenize: "forward",
7+
resolution: 9,
8+
doc: {
9+
id: "key",
10+
field: ["title", "content", "headers"],
11+
},
12+
};
13+
14+
const DEFAULT_SEARCH_RESULT_LENGTH = 60;
15+
16+
module.exports = (options) => ({
17+
extendPageData($page) {
18+
$page.content = getPageText($page);
19+
},
20+
alias: {
21+
"@SearchBox": path.resolve(__dirname, "src", "SearchBox.vue"),
22+
},
23+
define: {
24+
SEARCH_OPTIONS: options.search_options || defaultSearchOptions,
25+
SEARCH_MAX_SUGGESTIONS: options.maxSuggestions || 10,
26+
SEARCH_PATHS: options.searchPaths || null,
27+
SEARCH_HOTKEYS: options.searchHotkeys || "s",
28+
SEARCH_RESULT_LENGTH:
29+
Number(options.searchResultLength) || DEFAULT_SEARCH_RESULT_LENGTH,
30+
},
31+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "vuepress-plugin-flexsearch-plus",
3+
"version": "0.2.1",
4+
"description": "Next-Generation full text search library for Vuepress",
5+
"main": "index.js",
6+
"displayName": "flexsearch-plus",
7+
"publishConfig": {
8+
"access": "public"
9+
},
10+
"scripts": {
11+
"dev": "vuepress dev example/docs",
12+
"build": "vuepress build example/docs",
13+
"prepublishOnly": "npm run build && conventional-changelog -p angular -r 2 -i CHANGELOG.md -s"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/bajins/vuepress-plugin-flexsearch-plus"
18+
},
19+
"keywords": [
20+
"vuepress-plugin-flexsearch-plus",
21+
"vuepress-plugin-flexsearch",
22+
"vuepress-search",
23+
"search",
24+
"vuepress-plugin",
25+
"vuepress"
26+
],
27+
"author": {
28+
"name": "Bajins",
29+
"email": "[email protected]",
30+
"url": "https://github.com/bajins"
31+
},
32+
"license": "MIT",
33+
"homepage": "https://github.com/bajins/vuepress-plugin-flexsearch-plus#readme",
34+
"devDependencies": {
35+
"conventional-changelog-cli": "2.0.31",
36+
"he": "^1.2.0",
37+
"vuepress": "^1.4.1"
38+
},
39+
"dependencies": {
40+
"flexsearch": "^0.6.32"
41+
}
42+
}

0 commit comments

Comments
 (0)