Vuepress: 自带搜索工具不能搜索到中文内容的md

Created on 24 Mar 2020  ·  13Comments  ·  Source: vuejs/vuepress




  • [ ] I confirm that this is an issue rather than a question.




Bug report

Steps to reproduce

有两个md,一个是英文内容,一个是中文内容

What is expected?

md中有中文也能搜索

What is actually happening?

英文的能被搜索到,中文的不能被搜索到

Other relevant information

config.js

module.exports = {
  title: '标题',
  description: '测试项目',
  base: '/vuepress/',
  configureWebpack: {
    resolve: {
      alias: {
        '@alias': './assets/'
      }
    }
  },
  dest: './dist',
  themeConfig: {
    nav: [
      { text: 'Home', link: '/' },
      { text: 'Blog', link: '/blog/' },
      { text: 'About', link: '/about/' },
    ],
    sidebar: [
      {
        title: 'Blog',
        collapsable: false,
        children: [
          '/blog/',
          '/blog/first'
        ]
      }
    ],
    sidebarDepth: 3
  }
}
duplicated

Most helpful comment

All 13 comments

May be duplicated of #2242

https://vuepress.vuejs.org/zh/theme/default-theme-config.html?#algolia-%E6%90%9C%E7%B4%A2
是不是只能用 algolia搜索了?

https://vuepress.vuejs.org/zh/theme/default-theme-config.html?#algolia-%E6%90%9C%E7%B4%A2
是不是只能用 algolia搜索了?

@jimwmg 你可以去看下0.x版本的searchBox的代码,移植过来,以前版本是可以的

https://vuepress.vuejs.org/zh/theme/default-theme-config.html?#algolia-%E6%90%9C%E7%B4%A2
是不是只能用 algolia搜索了?

@jimwmg 你可以去看下0.x版本的searchBox的代码,移植过来,以前版本是可以的

试过几个0.x版本呢,都不行

@taojunnan 我也是一样的问题。卡了两天了以为我自己的问题。但是我github上下载其他人的代码,在我电脑上运行,是没有问题的。

https://vuepress.vuejs.org/zh/theme/default-theme-config.html?#algolia-%E6%90%9C%E7%B4%A2
是不是只能用 algolia搜索了?

@jimwmg 你可以去看下0.x版本的searchBox的代码,移植过来,以前版本是可以的

试过几个0.x版本呢,都不行

@Teacher-Li 这是我GitHub上随便找的例子运行是可以的,版本0.7.1链接

@taojunnan 我也是一样的问题。卡了两天了以为我自己的问题。但是我github上下载其他人的代码,在我电脑上运行,是没有问题的。

@liqingchang0365 vuepress版本问题,我对比了下1.x0.xsearchBox代码,1.x版本用的\b正则匹配单词边界,但不适用于中文,0.x版本直接用的indexOf().
0.x

item.title &&  item.title.toLowerCase().indexOf(query) > -1

1.x

`(?=.*\\b${escapeRegExp(word)})`

我也发现了,最近 #1557 的被合并了,导致不能搜索到中文了,希望官方能修复下吧
@ulivz

这是不能搜索到中文的仓库:https://github.com/zq99299/linux-tutorial

这是可以搜索中文的仓库:https://github.com/zq99299/note-book

@taojunnan 我也是一样的问题。卡了两天了以为我自己的问题。但是我github上下载其他人的代码,在我电脑上运行,是没有问题的。

@liqingchang0365 vuepress版本问题,我对比了下1.x0.xsearchBox代码,1.x版本用的\b正则匹配单词边界,但不适用于中文,0.x版本直接用的indexOf().
0.x

item.title &&  item.title.toLowerCase().indexOf(query) > -1

1.x

`(?=.*\\b${escapeRegExp(word)})`

感谢!
yarn add @vuepress/[email protected]
重启项目,问题解决

我目前还是通过:https://community.algolia.com/docsearch/ 解决的,本地启动的还是无法支持 全局 + 中文搜索

我目前还是通过:https://community.algolia.com/docsearch/ 解决的,本地启动的还是无法支持 全局 + 中文搜索

@jimwmg 申请不下来,有些主要还是公司内部查阅的文档,没有挂外网

紧急的话可以考虑先用 1.3 版本。

Closing this as duplicated of #2242

Was this page helpful?
0 / 5 - 0 ratings

Related issues

genedronek picture genedronek  ·  3Comments

alinnert picture alinnert  ·  3Comments

zeke picture zeke  ·  3Comments

FadySamirSadek picture FadySamirSadek  ·  3Comments

cfjedimaster picture cfjedimaster  ·  3Comments