Skip to content

Commit

Permalink
feat: support customize flexsearch tokenize option (#319)
Browse files Browse the repository at this point in the history
Co-authored-by: loenvom <[email protected]>
  • Loading branch information
loenvom and loenvom authored Mar 17, 2024
1 parent 22d4737 commit c634cb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions assets/js/flexsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -183,7 +184,7 @@ document.addEventListener("DOMContentLoaded", function () {
});

window.sectionIndex = new FlexSearch.Document({
tokenize: 'forward',
tokenize,
cache: 100,
document: {
id: 'id',
Expand Down
3 changes: 3 additions & 0 deletions exampleSite/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c634cb8

Please sign in to comment.