YunYouJun / hexo-theme-yun

☁️ A fast & light & lovely theme for Hexo. 一个对可爱自以为是的 Hexo 主题。
https://yun.yunyoujun.cn
MIT License
1.39k stars 168 forks source link

主题使用本地搜索,关闭了全文搜索后导致搜索功能不可用 #305

Closed lvjianzhao closed 2 years ago

lvjianzhao commented 2 years ago

最初我的本地搜索相关配置如下:

search:
  path: search.xml
  field: post
  content: true

但实际搜索时,发现由于是全文搜索,导致搜索结果过多(并且巨卡,输入文字后,半天才能显示到搜索框),所以关闭了全文搜索,更改后的配置如下:

search:
  path: search.xml
  field: post
  content: false

这样就会导致生成的search.xml文件中,每一段entry中没有content这个元素,导致js文件中的代码:content:e.querySelector("content").textContent执行时取不到值而控制台报错如下:

local-search.js:1 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'textContent')
at local-search.js:1:2024
at Array.map ()
at local-search.js:1:1938

期望结果: 1、对这块做个判断或异常处理吧。避免因search.xml文件中没有content元素而导致整个搜索功能不可用; 2、关于将content设置为true时,键盘输入需要过很久才能显示到搜索框中这个问题,也希望作者看下,如果我在别的地方编辑好了,粘贴过去,搜索还是很快的。

lvjianzhao commented 2 years ago

https://github.com/YunYouJun/hexo-theme-yun/discussions/304 上面这个 Discussions 也是我提的,描述的是同一个事情。

YunYouJun commented 2 years ago

该问题由于 https://github.com/next-theme/hexo-generator-searchdb 进行了一些更新所导致,我会尽快适配。

YunYouJun commented 2 years ago

使用 hexo-generator-searchdb 替代 hexo-generator-search

npm un hexo-generator-search
npm i hexo-generator-searchdb

更多配置见 hexo-generator-searchdb

Released in v1.10.1.

If you still have problems with your usage, please let me know.

lvjianzhao commented 2 years ago

好的,多谢,明天我试试,那么还有下面这个问题也可以通过使用hexo-generator-searchdb来解决么? 关于将content设置为true时,键盘输入需要过很久才能显示到搜索框中这个问题,也希望作者看下,如果我在别的地方编辑好了,粘贴过去,搜索还是很快的。

YunYouJun commented 2 years ago

好的,多谢,明天我试试,那么还有下面这个问题也可以通过使用hexo-generator-searchdb来解决么? 关于将content设置为true时,键盘输入需要过很久才能显示到搜索框中这个问题,也希望作者看下,如果我在别的地方编辑好了,粘贴过去,搜索还是很快的。

我认为已修复。

此外,在 v1.10.2 中继续修复了搜索框显示问题。

lvjianzhao commented 2 years ago

感谢作者,我升级到1.10.2后,搜索相关的问题都被解决了! 但还有个小小的bug,我在_config.yun.yml文件中,将wordcloud字段的enable设置为false,执行hexo clean all && hexo g && hexo s 后,还是可以看到tag对应的图标,最终通过修改hexo-theme-yun/_config.yml中相关配置,才可以关闭tag对应的图标

YunYouJun commented 2 years ago

tag 对应的图标是什么?能否截图说明。可以的话,新开一个 Issue。