Skip to content

全局搜索功能不好使 #123

Answered by kasie-zhang
aaja asked this question in Q&A
Discussion options

You must be logged in to vote

提供一种解决思路:

查看问题

打开浏览器,查看search功能是否引发了什么错误

控制台中可以看到search功能引发的错误是无法找到 search.xml 文件

但是 build 完成后,项目中已经生成 search.xml 文件,所以一定是某个 js 文件出错。

解决问题

在 themes\obsidian\js 目录下找到了 search.js 文件,该文件控制实现 search功能。

查看该文件下与 path 相关的变量,可以找到 getSearchFile 函数

var getSearchFile = function(){
    var path = "/search.xml";
    searchFunc(path, 'local-search-input', 'local-search-result');
};

将 path 变量更改为适合的路径:

验证是否成功

进入博客页面验证 search 功能是否可用!

完结,撒花 🌈 🌸

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by bennyxguo
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #98 on March 21, 2021 09:37.