Skip to content

Commit

Permalink
update flexsearch plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
bajins committed Mar 29, 2024
1 parent 385a8f9 commit 8d1621c
Show file tree
Hide file tree
Showing 14 changed files with 695 additions and 7,956 deletions.
5 changes: 3 additions & 2 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ module.exports = {
//filter:"",
count: "20",
}],
// 全文搜索 https://github.com/bajins/vuepress-plugin-flexsearch-plus
['flexsearch-plus'],
// 全文搜索
[require('./plugins/vuepress-plugin-flexsearch/index.js')],
// ['fulltext-search'],
// https://github.com/znicholasbrown/vuepress-plugin-code-copy
["vuepress-plugin-code-copy", true],
// https://github.com/ekoeryanto/vuepress-plugin-sitemap
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '17 10 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# 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

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
75 changes: 75 additions & 0 deletions .vuepress/plugins/vuepress-plugin-flexsearch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[![https://badgen.net/npm/v/vuepress-plugin-flexsearch](https://badgen.net/npm/v/vuepress-plugin-flexsearch)](https://www.npmjs.com/package/vuepress-plugin-flexsearch)
[![https://badgen.net/npm/dt/vuepress-plugin-flexsearch](https://badgen.net/npm/dt/vuepress-plugin-flexsearch)](https://www.npmjs.com/package/vuepress-plugin-flexsearch)
[![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)
[![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)

# vuepress-plugin-flexsearch

Next-Generation full text search library for Vuepress

> A great replacement of the default Vuepress search plugin.
## Installation

```bash
yarn add -D vuepress-plugin-flexsearch-plus
// or npm install vuepress-plugin-flexsearch-plus -D

```

## Usage

Use the default settings:

```js
// .vuepress/config.js

module.exports = {
plugins: [
['flexsearch'],
// other plugins
]
}
```

Or modify the settings to match your needs:

```js
// .vuepress/config.js

module.exports = {
plugins: [
['flexsearch', {
/*
Plugin custom options
*/
maxSuggestions: 10, // how many search suggestions to show on the menu, the default is 10.
searchPaths: ['path1', 'path2'], // an array of paths to search in, keep it null to search all docs.
searchHotkeys: ['s'], // Hot keys to activate the search input, the default is "s" but you can add more.
searchResultLength: 60, // the length of the suggestion result text by characters, the default is 60 characters.
/*
Default FlexSearch options
To override the default options you can see available options at https://github.com/nextapps-de/flexsearch
*/
search_options: {
encode: "icase",
tokenize: "forward",
resolution: 9,
doc: {
id: "key",
field: ["title", "content", "headers"],
}
}
}],
// other plugins
]
}
```

## Credit

Thanks to [nextapps-de/flexsearch](https://github.com/nextapps-de/flexsearch)

## Contributions

PRs are welcome :heart:
13 changes: 13 additions & 0 deletions .vuepress/plugins/vuepress-plugin-flexsearch/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# example

>
## Development

```bash
yarn dev
yarn build
```

For more details, please head VuePress's [documentation](https://v1.vuepress.vuejs.org/).

23 changes: 23 additions & 0 deletions .vuepress/plugins/vuepress-plugin-flexsearch/example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "example",
"version": "0.0.1",
"description": "",
"main": "index.js",
"authors": {
"name": "z3by",
"email": "[email protected]"
},
"repository": "/example",
"scripts": {
"dev": "vuepress dev docs",
"build": "vuepress build docs"
},
"license": "MIT",
"devDependencies": {
"@vuepress/plugin-back-to-top": "^1.0.0",
"@vuepress/plugin-medium-zoom": "^1.0.0",
"vuepress": "1.8.2"
},
"dependencies": {
}
}
31 changes: 31 additions & 0 deletions .vuepress/plugins/vuepress-plugin-flexsearch/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { path } = require("@vuepress/shared-utils");
const { getPageText } = require("./src/utils");

let defaultSearchOptions = {
encode: "icase",
tokenize: "forward",
resolution: 9,
doc: {
id: "key",
field: ["title", "content", "headers"],
},
};

const DEFAULT_SEARCH_RESULT_LENGTH = 60;

module.exports = (options) => ({
extendPageData($page) {
$page.content = getPageText($page);
},
alias: {
"@SearchBox": path.resolve(__dirname, "src", "SearchBox.vue"),
},
define: {
SEARCH_OPTIONS: options.search_options || defaultSearchOptions,
SEARCH_MAX_SUGGESTIONS: options.maxSuggestions || 10,
SEARCH_PATHS: options.searchPaths || null,
SEARCH_HOTKEYS: options.searchHotkeys || "s",
SEARCH_RESULT_LENGTH:
Number(options.searchResultLength) || DEFAULT_SEARCH_RESULT_LENGTH,
},
});
42 changes: 42 additions & 0 deletions .vuepress/plugins/vuepress-plugin-flexsearch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "vuepress-plugin-flexsearch-plus",
"version": "0.2.1",
"description": "Next-Generation full text search library for Vuepress",
"main": "index.js",
"displayName": "flexsearch-plus",
"publishConfig": {
"access": "public"
},
"scripts": {
"dev": "vuepress dev example/docs",
"build": "vuepress build example/docs",
"prepublishOnly": "npm run build && conventional-changelog -p angular -r 2 -i CHANGELOG.md -s"
},
"repository": {
"type": "git",
"url": "https://github.com/bajins/vuepress-plugin-flexsearch-plus"
},
"keywords": [
"vuepress-plugin-flexsearch-plus",
"vuepress-plugin-flexsearch",
"vuepress-search",
"search",
"vuepress-plugin",
"vuepress"
],
"author": {
"name": "Bajins",
"email": "[email protected]",
"url": "https://github.com/bajins"
},
"license": "MIT",
"homepage": "https://github.com/bajins/vuepress-plugin-flexsearch-plus#readme",
"devDependencies": {
"conventional-changelog-cli": "2.0.31",
"he": "^1.2.0",
"vuepress": "^1.4.1"
},
"dependencies": {
"flexsearch": "^0.6.32"
}
}
Loading

0 comments on commit 8d1621c

Please sign in to comment.