mirror of
https://github.com/ZetaKebab/quartz.git
synced 2025-09-13 04:35:21 +00:00
Make the search work for CJK characters
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
// import { FlexSearch, Charset } from "flexsearch"
|
||||||
import FlexSearch from "flexsearch"
|
import FlexSearch from "flexsearch"
|
||||||
|
import Charset from "flexsearch"
|
||||||
import { ContentDetails } from "../../plugins/emitters/contentIndex"
|
import { ContentDetails } from "../../plugins/emitters/contentIndex"
|
||||||
import { registerEscapeHandler, removeAllChildren } from "./util"
|
import { registerEscapeHandler, removeAllChildren } from "./util"
|
||||||
import { FullSlug, normalizeRelativeURLs, resolveRelative } from "../../util/path"
|
import { FullSlug, normalizeRelativeURLs, resolveRelative } from "../../util/path"
|
||||||
@@ -15,10 +17,9 @@ interface Item {
|
|||||||
type SearchType = "basic" | "tags"
|
type SearchType = "basic" | "tags"
|
||||||
let searchType: SearchType = "basic"
|
let searchType: SearchType = "basic"
|
||||||
let currentSearchTerm: string = ""
|
let currentSearchTerm: string = ""
|
||||||
const encoder = (str: string) => str.toLowerCase().split(/([^a-z]|[^\x00-\x7F])/)
|
|
||||||
let index = new FlexSearch.Document<Item>({
|
let index = new FlexSearch.Document<Item>({
|
||||||
charset: "latin:extra",
|
charset: "cjk:extra",
|
||||||
encode: encoder,
|
encode: Charset.CJK,
|
||||||
document: {
|
document: {
|
||||||
id: "id",
|
id: "id",
|
||||||
tag: "tags",
|
tag: "tags",
|
||||||
|
Reference in New Issue
Block a user