Closed test-lin closed 3 years ago
是 hexo-generator-search 生成的 search.xml 的问题
我在 _config.yml 里修改了 url 成 http://example.com/blog 在文章页可以正常访问搜索结果,经过几次验证,发现没有设置子目录的话 search.xml 里的 url 使用的是 相对路径。我就在搜索 js 里添加了路径开头判断。
// themes\melody\source\js\search\local-search.js:91
// show search results
if (isMatch) {
if (! dataUrl.startsWith('/')) {
dataUrl = '/' + dataUrl
}
str += '<div class="local-search__hit-item"><a href="' + dataUrl + '" class="search-result-title">' + dataTitle + '</a>' + '</div>'
count += 1
$('.local-search-stats__hr').show()
}
我的问题已经解决了,关闭的 issues 就交给你来关吧
感谢,最近没有时间看主题的issue。
欢迎提交一个PR,这边合入~
Melody Information
yarn Version: 1.22.4 hexo-cli Version: 4.2.0 Melody Version: 1.9.0 hexo-generator-search Version: 2.4.2
Platform: Windows 7
Browser: edge
_config.melody.yml
Expected behavior
跳转到搜索结果页
http://localhost:4000/2019/04/ssl-encrypt/
Actual behavior
实际跳转到 http://localhost:4000/2019/04/algorithm-roman-to-integer/2019/04/ssl-encrypt/
Steps to reproduce the behavior
Other
从访问错误页返回,重新打开搜索,搜索关键词还在,无搜索结果,需要删除一部分才能触发