iissnan / hexo-theme-next

Elegant theme for Hexo.
http://notes.iissnan.com
MIT License
15.88k stars 3.62k forks source link

5.1.0使用algolia搜索问题 #1084

Open panoshu opened 8 years ago

panoshu commented 8 years ago

Expected behavior (预期行为)

搜索菜单可点击且弹出搜索页面

Actual behavior (实际行为)

搜索菜单在菜单栏的居中位置,而且点击无反应

Steps to reproduce the behavior (重现步骤)

主题配置文件设置 algoliasearch: enable: true 站点配置文件设置 algolia: applicationID: '**' apiKey: '_' adminApiKey: '' indexName: '**' chunkSize: 5000

NexT Informations

Add the ✔ sign before an item which is affected by this behavior.

NexT Version:

NexT Scheme:

liujiayi771 commented 8 years ago

我也有这个问题啊,不知道怎么解决

iissnan commented 8 years ago

@panoshu 主题配置文件里的 applicationID, apiKeyindexName 都必须配置。另外,能打开浏览器的 Console 看下是否有什么错误没有

ehlxr commented 8 years ago

我的点击后:http://ehlxr.me/undefined image

Console报错: image

zlc1994 commented 8 years ago

@ehlxr 这是因为hexo-algolia的作者并没有把post.path进行index,所以data.path是undefined,你可以自己修改hexo-algolia里面的command.js,把path加进去,重新index。

ehlxr commented 8 years ago

3Q,我试试

innote commented 7 years ago

大家如果遇到同樣問題, 請install npm install hexo-algolia@0.2.0, 然後在站点找到package.json, 把裏面的hexo-algolia, 換成 "hexo-algolia": "^0.2.0"

再重新index, 就可以了。

shevonwang commented 7 years ago

@zlc1994 请问要怎么加path呢

innote commented 7 years ago

@shevonwang 去node_modules/hexo-algolia/lib, 找到command.js,加path

var storedPost = _.pick(data, ['title', 'date', 'slug', 'path', 'content', 'excerpt', 'objectID']);
xxllll commented 7 years ago

@innote 请问为何我用了0.2.0以及加了路径,仍然无法点按搜索。。

lovingzw commented 7 years ago

之前配置成功了,链接也正常。但是今天又404了...

innote commented 7 years ago

@xxllll 和 @lovingzw 你們還是要再index多一次呀!!!!

lovingzw commented 7 years ago

发现是在 algolia indice设置的问题。解决了,thanks! @innote

Southhill commented 7 years ago

我在hexo-algolia0.1.1的版本上修改了comand.js文件(第30行的位置,添加了‘path’),之后重新运行了命令'hexo algolia',将修改后的版本部署好之后,搜索出来的链接点击果然跳转到正确的位置了。

consen commented 7 years ago

https://github.com/iissnan/hexo-theme-next/blob/master/layout/_partials/header.swig#L54-L56

          {% elseif config.search %}
            <a href="javascript:;" class="popup-trigger">
          {% endif %}

除了在主题配置文件中配置:

algolia_search:
  enable: true

难道还需要在站点配置文件中添加'search'字段?

search: true
iissnan commented 7 years ago

@consen master 分支上这个地方的判断加上了 theme.algolia_search.enable

{% elseif config.search || theme.algolia_search.enable %}
        <a href="javascript:;" class="popup-trigger">
{% endif %}
hy08 commented 7 years ago

Theme version

version: 5.1.0 这个版本中,var storedPost = .pick(data, ['title', 'date', 'slug', 'path', 'content', 'excerpt', 'objectID']);的确应该是这样,而我的原先是var storedPost = .pick(data, ['title', 'date', 'slug', 'content', 'excerpt', 'permalink']); 因此不仅要添加path字段,还要修改最后的permalink字段

WardLIN commented 7 years ago

@iissnan 我发现搜索出来的条目的链接是undefined,查看了一下algolia官网返回的json里并没有包含path对象,请问是什么原因?(hexo-algolia是0.2.0版本的了,common.js配置正确)

iissnan commented 7 years ago

What attributes did you get?

NexT release 5.1.0 should be compatible with hexo-algolia both 0.2.0 and 0.1.0.

WardLIN commented 7 years ago

@iissnan I got attributes such as title,slug,contentStrip,objectID,_highlightResult,_rankingInfo but without path,so 'data.path' is undefined! 1

kitianFresh commented 7 years ago

I got the same problem too, Algolia can't response a correct urls for search results after I add 'path' and modify hexo-algolia to 0.2.0

longhaiqwe commented 7 years ago

我遇到的一个情况是一开始配置了swiftype_key,然后更改成local或者algolia的方式都不行,也找了好久,只需要把站点配置文件里面的swiftype_key选项去掉就好了。看看有没有能够给一些人提供思路。

Yelloboy commented 7 years ago

出现搜索框搜索不到任何东西,请教一下

thyeun commented 7 years ago

@Yelloboy, 我可以具體的了解你的問題嗎?, 因爲搜索框搜索不到, 可以是因爲你的布置不完善/不對。

forsunwell commented 6 years ago

@thyeun 请问下,我这里出现如下错误,是什么原因? `INFO [Algolia] Index cleared. INFO [Algolia] Starting indexation...

E:\code\hexo\node_modules\hexo-algolia\lib\command.js:99 throw err; ^ AlgoliaSearchNetworkError: connect ETIMEDOUT 103.6.130.169:443 at ClientRequest.error (E:\code\hexo\node_modules\algoliasearch\src\server\builds\node.js:228:14) at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketErrorListener (_http_client.js:387:9) at emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) `

Next版本: # Theme version version: 5.1.4

软件包版本: tnpm install hexo-algolia@0.2.0

ivan-nginx commented 6 years ago

NexT is rebased into organization repo. If you want new feature, fix, or support, create new in NexT v6.x repo (desirable in English).

There is instructions on English or Chinese how to update from v5.1.x to v 6.x

You also may read this for details.

ivan-nginx commented 6 years ago

I don't know what's happen here, but it seems this is not solved or wrong fixed issue and @thyeun trying to do best things here.


But issue too old, IDK why it's 2 years ago and still opened.

thyeun commented 6 years ago

@innote 也是我的號, 在這裏先說聲對不起, @iissnan 可能已經不是這個project的站長了, 因爲我不在contributor list所以在這裏的解答是不給其他人接受的,我也不會再給任何解答。


@innote also is my account, first of all, i'm sorry everyone, @iissnan might be not the project leader anymore, and because i'm not in the contributor list, i should not given any temporary solution here, it might not accepted by others, so for now on, i wont answering any topic that related with this project.


Peace out!!!! @ivan-nginx pls don't mention my name here, and i'm sure you can provided better solid solution for the user. thanks!

sli1989 commented 6 years ago

@forsunwell The use of Algolia Search maybe updated. Can you follow this instruction to reproduce your problem? 1-7 steps. Then, the detailed steps needs too.

MoBenw commented 6 years ago

我这里是因为permalink 的路径错误他显示成了http://yoursite.com/ 请问有什么办法解决吗 @innote @lovingzw @iissnan

aline2013 commented 6 years ago

@MoBenw 同样出现http://yoursite.com/这个问题,现已解决

  1. 原本5.1.0就出现改问题,但一直没注意修改。其实,修改方法:就是楼上 @zlc1994 所说,缺少path,修改完command.js后,要重新hexo alglia(最好重新hexo algolia之前最好把algolia网站上indices模块的index缓存清空)

  2. 升级博客版本后,hexo: 3.7.0, next: 6.4.0,hexo-algolia: ^1.2.5 并依照Algolia Search for NexT更新了主题下的theme-next-algolia-instant-search。 此时发现,新的theme-next-algolia-instant-search已经支持permalink,这个permalink就是你在站点_comfig.yml下配置的。所以,此时你需要做的仅仅是:重新hexo alglia(最好重新hexo algolia之前最好把algolia网站上indices模块的index缓存清空)

如下,我的站点_comfig.yml

url: https://www.aline2013.com
root: /
permalink: article/:title.html
permalink_defaults: article/:title.html

那么,跳转的路径是 https://www.aline2013.com/article/blog-inhance_deep.html

monkeyip commented 5 years ago

@MoBenw 同样出现http://yoursite.com/这个问题,现已解决

  1. 原本5.1.0就出现改问题,但一直没注意修改。其实,修改方法:就是楼上 @zlc1994 所说,缺少path,修改完command.js后,要重新hexo alglia(最好重新hexo algolia之前最好把algolia网站上indices模块的index缓存清空)
  2. 升级博客版本后,hexo: 3.7.0, next: 6.4.0,hexo-algolia: ^1.2.5 并依照Algolia Search for NexT更新了主题下的theme-next-algolia-instant-search。 此时发现,新的theme-next-algolia-instant-search已经支持permalink,这个permalink就是你在站点_comfig.yml下配置的。所以,此时你需要做的仅仅是:重新hexo alglia(最好重新hexo algolia之前最好把algolia网站上indices模块的index缓存清空)

如下,我的站点_comfig.yml

url: https://www.aline2013.com
root: /
permalink: article/:title.html
permalink_defaults: article/:title.html

那么,跳转的路径是 https://www.aline2013.com/article/blog-inhance_deep.html

我的hexo都是3.8.0了,也是出现http://yoursite.com/这个问题,而且我也更改了站点配置文件下的rul为自己的博客地址,但是结果还是不好使,顺便问下hexo algolia之前最好把algolia网站上indices模块的index缓存清空,这个操作在哪做啊。

monkeyip commented 5 years ago

@Yelloboy, 我可以具體的了解你的問題嗎?, 因爲搜索框搜索不到, 可以是因爲你的布置不完善/不對。

你好,我也是同样的问题,这个algolia经常不好使,前段时间刚弄好,发现搜不到最开始第一篇文章,但是能搜到后面的,我很疑惑,后面新增文章也都搜不到,我怀疑是没有加index的原因。

然后我就重新hexo algolia了,也都正常,但是出现以下提示:

INFO Start processing INFO [Algolia] Identified 0 posts to index. INFO [Algolia] Clearing index... INFO Files loaded in 2.39 s INFO 0 files generated in 405 ms INFO [Algolia] Index cleared. INFO [Algolia] Starting indexation... INFO [Algolia] Import done. INFO [Algolia] Highlight tag definition success.

很明显这次更新0条index了,直接导致我在博客里打开搜索一条都搜不到,搜索框右下角本该有的algolia图标也没了。

image

还请帮忙解答下呢?谢谢。