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

Hope the Chinese search support #222

Open
TenTu0121 opened this issue Jul 16, 2020 · 5 comments
Open

Hope the Chinese search support #222

TenTu0121 opened this issue Jul 16, 2020 · 5 comments

Comments

@TenTu0121
Copy link

希望能有中文搜索支持。

@reuixiy
Copy link
Owner

reuixiy commented Jul 20, 2020

暂不支持的原因见 #165

@sosiristseng
Copy link

FYI, fuse.js supports Chinese. An example could be found in this Hugo partial theme.

@TenTu0121
Copy link
Author

Thinks.

@reuixiy reuixiy self-assigned this Jan 9, 2021
@reuixiy reuixiy added this to the v4.6.0 milestone Jan 9, 2021
reuixiy added a commit that referenced this issue May 23, 2021
updates #222

Co-authored-by: reuixiy <reuixiy@gmail.com>
@swang-harbin
Copy link

lunr-languages 现在支持中文了,使用的是 nodejieba,我在 blog/layouts/partials/third-party/lunr-search.html 文件中将 lunr-language 的版本进行了更新:

{{- $scripts := slice "https://cdn.jsdelivr.net/npm/lunr@2.3.9/lunr.min.js" -}}
{{- if ne .Site.Language.Lang "en" -}}
    {{- $supported := slice "ar" "da" "de" "du" "es" "fi" "fr" "hu" "it" "ja" "nl" "no" "pt" "ro" "ru" "sv" "tr" "vi" "zh"  -}}
    {{- if in $supported .Site.Language.Lang -}}
        {{- if eq .Site.Language.Lang "ja" -}}
            {{- $scripts = union $scripts (slice "https://cdn.jsdelivr.net/npm/lunr-languages@1.9.0/tinyseg.js") -}}
        {{- end -}}
        {{- $scripts = union $scripts (slice "https://cdn.jsdelivr.net/npm/lunr-languages@1.9.0/min/lunr.stemmer.support.min.js") -}}
        {{- $scripts = union $scripts (slice (printf "https://cdn.jsdelivr.net/npm/lunr-languages@1.9.0/min/lunr.%s.min.js" .Site.Language.Lang)) -}}
    {{- else -}}
        {{- warnf "The site language %q isn't supported by lunr, the search results might be suboptimal. Supported languages are: %q" .Site.Language.Lang $supported -}}
    {{- end -}}
{{- end -}}

{{- $scripts = union $scripts (slice "js/lunr-search.js") -}}
{{- return $scripts -}}

但是搜索时报错:

Uncaught TypeError: Cannot read property 'cut' of undefined
    at e.Builder.r.zh.tokenizer (lunr.zh.min.js:1)
    at e.Builder.add (lunr.min.js:6)
    at e.Builder.<anonymous> (meme.min.111eed27d8910a11822d3084ae2d0a86388b9ccd9024cd2fd6216233c4eb8818.js:1)
    at e (lunr.min.js:6)
    at XMLHttpRequest.<anonymous> (meme.min.111eed27d8910a11822d3084ae2d0a86388b9ccd9024cd2fd6216233c4eb8818.js:1)

找不到 nodejieba 的 cut 方法,请问有什么解决办法吗?

@StudentWeis
Copy link

同求,现在有很多解决方案啦。

ulmefors pushed a commit to ulmefors/hugo-theme-meme that referenced this issue Jan 22, 2024
updates reuixiy#222

Co-authored-by: reuixiy <reuixiy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants