Skip to content
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

Merged
merged 15 commits into from
Jul 26, 2019
Merged

Refactor search services #1012

merged 15 commits into from
Jul 26, 2019

Conversation

stevenjoezhang
Copy link
Contributor

@stevenjoezhang stevenjoezhang commented Jul 25, 2019

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines.
  • Tests for the changes was maked (for bug fixes / features).
    • Muse | Mist have been tested.
    • Pisces | Gemini have been tested.
  • Docs in NexT website have been added / updated (for features).

PR Type

What kind of change does this PR introduce?

  • Bugfix.
  • Feature.
  • Code style update (formatting, local variables).
  • Refactoring (no functional changes, no api changes).
  • Build related changes.
  • CI related changes.
  • Documentation content changes.
  • Other... Please describe:

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?

  • Screenshots with this changes: N/A
  • Link to demo site with this changes: N/A

How to use?

In NexT _config.yml:

...

Does this PR introduce a breaking change?

  • Yes.
  • No.

@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@theme-next theme-next deleted a comment Jul 25, 2019
@@ -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' %}
Copy link
Member

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

Copy link
Contributor Author

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>

Copy link
Member

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.

Copy link
Contributor Author

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,处理这样的情况。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
这是因为comment的位置比较尴尬,不能在bodyEnd也不是postBodyEnd 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外一个问题是各种share,也是同时存在DOM元素和脚本。真蛋疼..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

share完全不知道怎么搞,在我的基于next的主题里是全删了,反正我也不用,哈哈😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以这咋办呀

Copy link
Member

@jiangtj jiangtj Jul 26, 2019

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,美滋滋

@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@stevenjoezhang stevenjoezhang added this to the v7.3.0 milestone Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@theme-next theme-next deleted a comment Jul 26, 2019
@stevenjoezhang stevenjoezhang merged commit b01d825 into master Jul 26, 2019
@delete-merged-branch delete-merged-branch bot deleted the search branch July 26, 2019 12:41
tongluyang pushed a commit to tongluyang/hexo-theme-next that referenced this pull request Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Swiftype Search doesn't work
3 participants