feat: support customize flexsearch tokenize option (#319)

Co-authored-by: loenvom <loenvom@qq.com>
This commit is contained in:
loenvom 2024-03-18 02:50:22 +08:00 committed by GitHub
parent 22d4737b99
commit c634cb83eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -172,8 +172,9 @@ document.addEventListener("DOMContentLoaded", function () {
// Preload the search index.
async function preloadIndex() {
const tokenize = '{{- site.Params.search.flexsearch.tokenize | default "forward" -}}';
window.pageIndex = new FlexSearch.Document({
tokenize: 'forward',
tokenize,
cache: 100,
document: {
id: 'id',
@ -183,7 +184,7 @@ document.addEventListener("DOMContentLoaded", function () {
});
window.sectionIndex = new FlexSearch.Document({
tokenize: 'forward',
tokenize,
cache: 100,
document: {
id: 'id',

View File

@ -136,6 +136,9 @@ params:
flexsearch:
# index page by: content | summary | heading | title
index: content
# full | forward | reverse | strict
# https://github.com/nextapps-de/flexsearch/#tokenizer-prefix-search
tokenize: forward
editURL:
enable: true