chaooo / hexo-theme-BlueLake

A simple theme for Hexo with great performance on different devices .
MIT License
328 stars 121 forks source link

关于本地搜索的问题 #105

Open HiedanoAkyuu opened 4 years ago

HiedanoAkyuu commented 4 years ago

我把根目录下的root设置成我的subdirectory路径,然后发现搜索无法正常使用。控制台返回GET /content.json 404 0.149 ms - 151

rn7s2 commented 4 years ago

貌似是因为作者没有考虑搜索时的子目录问题? 将/themes/BlueLake/source/js/search.json.js里的"/content.json"改成"/your subdirectory/content.json"就可以显示搜索结果,但是搜索结果的链接是不正确的,仍然缺少子目录名。

rn7s2 commented 4 years ago

@HiedanoAkyuu

我有一个不是很优雅的修补方案:

  1. 将/themes/BlueLake/source/js/search.json.js里的xhr.open('GET', '/content.json', true);改成xhr.open('GET', '/YOUR SUBDIRECTORY/content.json', true);
  2. /themes/BlueLake/layout/_partial/search.jade里的a(href="/{path}",title="{title}")改成a(href="/YOUR SUBDIRECTORY/{path}",title="{title}")

这样搜索功能就正常了。

Nana2mini commented 4 years ago

npm install hexo-generator-json-content --save