From 693f528bb0ec5e228acd54e1f50b07981ef615a2 Mon Sep 17 00:00:00 2001 From: Octobug Date: Sat, 4 Nov 2023 13:13:23 +0800 Subject: [PATCH] fix(search): work around with Intl.Segmenter on Firefox --- .vitepress/theme/search.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.vitepress/theme/search.ts b/.vitepress/theme/search.ts index 7f7ad33..bd1114b 100644 --- a/.vitepress/theme/search.ts +++ b/.vitepress/theme/search.ts @@ -1,4 +1,9 @@ export function tokenize(text: string): Array { + // Firefox doesn't support Intl.Segmenter currently + if (!("Segmenter" in Intl)) { + return text.split(" "); + } + // @ts-ignore: seems like Intl.Segmenter is not supported by the lang server const segmenter = new Intl.Segmenter("cn", { granularity: "word" }); const words = Array.from(segmenter.segment(text)).map(