-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor search services #1012
Refactor search services #1012
Conversation
@@ -1,7 +1,5 @@ | |||
{% if theme.algolia_search.enable %} | |||
{% include 'algolia-search.swig' %} | |||
{% elif theme.swiftype_key %} | |||
{% include 'swiftype.swig' %} | |||
{% elif theme.local_search.enable %} | |||
{% include 'localsearch.swig' %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move layout/_partials/search/*
to layout/_third-party/search/*
?
I don't think it's necessary to have two layouts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jQuery is loaded at the end of the body. Local search depends on jQuery. Put the script here will cause an $
not defined error. Maybe we can open another PR to move jQuery to <head>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can open another PR to move jQuery to
<head>
Don't do this.
我的意思是将原本在菜单那的搜索弹出框布局移到底部,与脚本合并,弹出框与其所在的位置没有关联,两个文件变一个,更便于维护
I mean to move the search popup layout that was originally in the menu to the bottom, merge with the script, the popup is not associated with its location, and the two files become one, which is easier to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
两个文件变一个,更便于维护
但是将DOM和<script>
分离更加优美。在layout
中,<script>
只应存在于_scripts
和_third-party
中,各种DOM存在于_partials
中。就像评论系统,使用inject.comment向评论区写入DOM,使用inject.bodyend写入脚本。它们应该是分开的。
还是需要开一个新的PR,处理这样的情况。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外一个问题是各种share,也是同时存在DOM元素和脚本。真蛋疼..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
share完全不知道怎么搞,在我的基于next的主题里是全删了,反正我也不用,哈哈😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以这咋办呀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不知道,那就暂时不管share咯,以后想到怎么处理了在弄。
这是我的搜索重构 jiangtj/hexo-theme-cake#11
加menu注入点,试了把localsearch提取出去,等GitHub包管理出了,可以这样搞啊,反正localsearch本来就要装个hexo插件:joy:
等你这个合并,我修改下插件直接CDN引用localsearch.js,美滋滋
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue resolved: #831
https://juejin.im/post/5bbdc8d8e51d450e5e0cb269
https://github.com/iissnan/hexo-theme-next/pull/694/files
https://github.com/wzpan/hexo-generator-search
https://github.com/wzpan/hexo-theme-freemind/blob/master/source/js/search.js
What is the new behavior?
How to use?
In NexT
_config.yml
:Does this PR introduce a breaking change?