Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add support for Fuse.js #104

Merged
merged 5 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ To see this theme in action, here is a live [demo site](https://hugodoit.pages.d
* Some beautiful **CSS animations**
* Easy-to-use and self-expanding **table of contents**
* More **social links**, **share sites** and **comment system**
* **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/)
* **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/) or [Fuse.js](https://fusejs.io/)
* **Copy code** to clipboard with one click
* Extended Markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
* Extended Markdown syntax for **ruby annotation**
Expand Down Expand Up @@ -116,7 +116,7 @@ the DoIt theme may be more suitable for you.

### Extended Features

* **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/)
* **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/) or [Fuse.js](https://fusejs.io/)
* **Twemoji** supported
* Automatically **highlighting** code
* **Copy code** to clipboard with one click
Expand Down Expand Up @@ -188,6 +188,7 @@ Thanks to the authors of following resources included in the theme:
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [Fuse.js](https://fusejs.io/)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
Expand Down
5 changes: 3 additions & 2 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ DoIt 主题增加了许多新的功能与配置项,查看[变更日志](https:
* 一些美观的 **CSS 动画**
* 易用和自动展开的**文章目录**
* 支持更多的**社交链接**、**网站分享**和**评论系统**
* 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 的**搜索**
* 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 或 [Fuse.js](https://fusejs.io/) 的**搜索**
* 一键**复制代码**到剪贴板
* 支持基于 **[Font Awesome](https://fontawesome.com/) 图标**的扩展 Markdown 语法
* 支持**上标注释**的扩展 Markdown 语法
Expand Down Expand Up @@ -113,7 +113,7 @@ DoIt 主题增加了许多新的功能与配置项,查看[变更日志](https:

### 扩展功能

* 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 的**搜索**
* 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 或 [Fuse.js](https://fusejs.io/) 的**搜索**
* 支持 **Twemoji**
* 支持**代码高亮**
* 一键**复制代码**到剪贴板
Expand Down Expand Up @@ -185,6 +185,7 @@ DoIt 主题中用到了以下项目,感谢它们的作者:
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [Fuse.js](https://fusejs.io/)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
Expand Down
4 changes: 3 additions & 1 deletion assets/data/cdn/jsdelivr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ libFiles:
cookieconsentCSS: cookieconsent@3.1.1/build/cookieconsent.min.css
cookieconsentJS: cookieconsent@3.1.1/build/cookieconsent.min.js
# twikoo@1.4.0-alpha.2 https://twikoo.js.org/
twikooJS: twikoo@1.4.0-alpha.2/dist/twikoo.all.min.js
twikooJS: twikoo@1.4.0-alpha.2/dist/twikoo.all.min.js
# fusejs@6.4.6 https://fusejs.io/
fuseJS: fuse.js@6.4.6/dist/fuse.min.js
2 changes: 1 addition & 1 deletion assets/js/theme.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/theme.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion assets/lib/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ gitalk@1.7.2 https://github.com/gitalk/gitalk
valine@1.4.14 https://valine.js.org/
waline@0.17.0 https://waline.js.org/
cookieconsent@3.1.1 https://github.com/osano/cookieconsent
twikoo@1.4.0-alpha.2 https://twikoo.js.org/
twikoo@1.4.0-alpha.2 https://twikoo.js.org/
fusejs@6.4.6 https://fusejs.io/
1 change: 1 addition & 0 deletions assets/lib/fuse/fuse.min.js

Large diffs are not rendered by default.

39 changes: 36 additions & 3 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ enableEmoji = true
# Search config
[languages.en.params.search]
enable = true
# type of search engine ("lunr", "algolia")
# type of search engine ("lunr", "algolia", "fuse")
type = "algolia"
# max index length of the chunked content
contentLength = 4000
Expand All @@ -137,6 +137,17 @@ enableEmoji = true
index = "en_index"
appID = "5YGRNRQK1G"
searchKey = "0ff6874805de24b84aa1d5ebccad56cd"
[languages.en.params.search.fuse]
# https://fusejs.io/api/options.html
isCaseSensitive = false
minMatchCharLength = 2
findAllMatches = false
location = 0
threshold = 0.3
distance = 100
ignoreLocation = false
useExtendedSearch = false
ignoreFieldNorm = false
# Home page config
[languages.en.params.home]
# amount of RSS pages
Expand Down Expand Up @@ -326,7 +337,7 @@ enableEmoji = true
# 搜索配置
[languages.zh-cn.params.search]
enable = true
# 搜索引擎的类型 ("lunr", "algolia")
# 搜索引擎的类型 ("lunr", "algolia", "fuse")
type = "algolia"
# 文章内容最长索引长度
contentLength = 4000
Expand All @@ -344,6 +355,17 @@ enableEmoji = true
index = "zh_cn_index"
appID = "5YGRNRQK1G"
searchKey = "0ff6874805de24b84aa1d5ebccad56cd"
[languages.zh-cn.params.search.fuse]
# https://fusejs.io/api/options.html
isCaseSensitive = false
minMatchCharLength = 2
findAllMatches = false
location = 0
threshold = 0.3
distance = 100
ignoreLocation = false
useExtendedSearch = false
ignoreFieldNorm = false
# 主页信息设置
[languages.zh-cn.params.home]
# RSS 文章数目
Expand Down Expand Up @@ -521,7 +543,7 @@ enableEmoji = true
# Search config
[languages.fr.params.search]
enable = true
# type of search engine ("lunr", "algolia")
# type of search engine ("lunr", "algolia", "fuse")
type = "algolia"
# max index length of the chunked content
contentLength = 4000
Expand All @@ -539,6 +561,17 @@ enableEmoji = true
index = "fr_index"
appID = "5YGRNRQK1G"
searchKey = "0ff6874805de24b84aa1d5ebccad56cd"
[languages.fr.params.search.fuse]
# https://fusejs.io/api/options.html
isCaseSensitive = false
minMatchCharLength = 2
findAllMatches = false
location = 0
threshold = 0.3
distance = 100
ignoreLocation = false
useExtendedSearch = false
ignoreFieldNorm = false
# Home page config
[languages.fr.params.home]
# amount of RSS pages
Expand Down
3 changes: 2 additions & 1 deletion exampleSite/content/about/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ math:

#### Extended Features

* :(fas fa-search fa-fw): **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/)
* :(fas fa-search fa-fw): **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/) or [Fuse.js](https://fusejs.io/)
* :(far fa-grin-tongue-wink fa-fw): **Twemoji** supported
* :(fas fa-code fa-fw): Automatically **highlighting** code
* :(far fa-copy fa-fw): **Copy code** to clipboard with one click
Expand Down Expand Up @@ -98,6 +98,7 @@ Thanks to the authors of following resources included in the theme:
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [Fuse.js](https://fusejs.io/)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
Expand Down
3 changes: 2 additions & 1 deletion exampleSite/content/about/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ math:

#### 扩展功能

* :(fas fa-search fa-fw): 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 的**搜索**
* :(fas fa-search fa-fw): 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 或 [Fuse.js](https://fusejs.io/) 的**搜索**
* :(far fa-grin-tongue-wink fa-fw): 支持 **Twemoji**
* :(fas fa-code fa-fw): 支持**代码高亮**
* :(far fa-copy fa-fw): 一键**复制代码**到剪贴板
Expand Down Expand Up @@ -99,6 +99,7 @@ DoIt 主题中用到了以下项目,感谢它们的作者:
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [Fuse.js](https://fusejs.io/)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ draft: false
description: "Author Fallback Test"
categories: [Tests]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ authors: ["Alice"]
description: "Single Author Test"
categories: [Tests]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/tests/bilibili-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: "Bilibili Tests"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: "Built-in Shortcodes Tests"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/tests/echarts-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: "Echarts Tests"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ categories: [Tests]
authors: [PCloud]
lightgallery: true
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description: "Friend link test"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/posts/tests/katex-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors: [PCloud]
math:
enable: true
hiddenFromHomePage: true

hiddenFromSearch: true
---

<!--more-->
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/tests/mapbox-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: "Mapbox Tests"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/tests/markdown-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description: "Test basic markdown rendering"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/tests/mermaid-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: "Mermaid Tests"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ authors: ["Alice", "Bob", "Catherine", "David", "Edward", "Frank", "George", "Ha
description: "Multr Author Test"
categories: [Tests]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ authors: ["Alice", "Bob", "大云云"]
description: "多作者测试"
categories: [Tests]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/tests/music-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: "Music Tests"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/tests/showcase-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ authors: [PCloud]
hiddenFromHomePage: true
toc: false
pageStyle: wide
hiddenFromSearch: true
---

<!--more-->
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/tests/typeit-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: "Typeit Tests"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->
Expand Down
32 changes: 27 additions & 5 deletions exampleSite/content/posts/theme-documentation-basics/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ Please open the code block below to view the complete sample configuration :(far
# {{< version 0.2.0 >}} Search config
[params.search]
enable = true
# type of search engine ("lunr", "algolia")
type = "lunr"
# type of search engine ("lunr", "algolia","fuse")
type = "fuse"
# max index length of the chunked content
contentLength = 4000
# placeholder of the search bar
Expand All @@ -247,7 +247,17 @@ Please open the code block below to view the complete sample configuration :(far
index = ""
appID = ""
searchKey = ""

[params.search.fuse]
# {{< version 0.2.12 >}} https://fusejs.io/api/options.html
isCaseSensitive = false
minMatchCharLength = 2
findAllMatches = false
location = 0
threshold = 0.3
distance = 100
ignoreLocation = false
useExtendedSearch = false
ignoreFieldNorm = false
# Header config
[params.header]
# desktop header mode ("fixed", "normal", "auto")
Expand Down Expand Up @@ -1052,8 +1062,8 @@ Here is the search configuration in your [site configuration](#site-configuratio
```toml
[params.search]
enable = true
# type of search engine ("lunr", "algolia")
type = "lunr"
# type of search engine ("lunr", "algolia", "fuse")
type = "fuse"
# max index length of the chunked content
contentLength = 4000
# placeholder of the search bar
Expand All @@ -1070,11 +1080,23 @@ Here is the search configuration in your [site configuration](#site-configuratio
index = ""
appID = ""
searchKey = ""
[params.search.fuse]
# {{< version 0.2.12 >}} https://fusejs.io/api/options.html
isCaseSensitive = false
minMatchCharLength = 2
findAllMatches = false
location = 0
threshold = 0.3
distance = 100
ignoreLocation = false
useExtendedSearch = false
ignoreFieldNorm = false
```

{{< admonition note "How to choose search engine?" >}}
The following is a comparison of two search engines:

* `fuse`: simple, no need to synchronize `index.json`, no limit for `contentLength`, high performance
* `lunr`: simple, no need to synchronize `index.json`, no limit for `contentLength`,
but high bandwidth and low performance (Especially for Chinese which needs a large segmentit library)
* `algolia`: high performance and low bandwidth, but need to synchronize `index.json` and limit for `contentLength`
Expand Down
Loading