hexo-theme-next icon indicating copy to clipboard operation
hexo-theme-next copied to clipboard

5.1.0使用algolia搜索问题

Open panoshu opened this issue 7 years ago • 32 comments

Expected behavior (预期行为)

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

Actual behavior (实际行为)

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

Steps to reproduce the behavior (重现步骤)

主题配置文件设置 algolia_search: 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:

  • Master
  • Latest Release ✔
  • Old version -

NexT Scheme:

  • All schemes
  • Muse
  • Mist
  • Pisces ✔

Other Informations (Like Browser, System, Screenshots)

panoshu avatar Aug 28 '16 12:08 panoshu

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

liujiayi771 avatar Oct 17 '16 03:10 liujiayi771

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

iissnan avatar Oct 17 '16 07:10 iissnan

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

Console报错: image

ehlxr avatar Oct 18 '16 09:10 ehlxr

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

zlc1994 avatar Oct 18 '16 10:10 zlc1994

3Q,我试试

ehlxr avatar Oct 18 '16 12:10 ehlxr

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

再重新index, 就可以了。

innote avatar Nov 12 '16 01:11 innote

@zlc1994 请问要怎么加path呢

shevonwang avatar Nov 15 '16 11:11 shevonwang

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

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

innote avatar Nov 15 '16 12:11 innote

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

xxllll avatar Dec 06 '16 07:12 xxllll

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

lovingzw avatar Dec 06 '16 08:12 lovingzw

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

innote avatar Dec 06 '16 10:12 innote

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

lovingzw avatar Dec 07 '16 08:12 lovingzw

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

Southhill avatar Dec 25 '16 10:12 Southhill

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

consen avatar Jan 03 '17 09:01 consen

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

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

iissnan avatar Feb 17 '17 07:02 iissnan

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字段

hy08 avatar Mar 04 '17 05:03 hy08

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

WardLIN avatar Mar 19 '17 09:03 WardLIN

What attributes did you get?

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

iissnan avatar Mar 19 '17 10:03 iissnan

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

WardLIN avatar Mar 19 '17 11:03 WardLIN

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

kitianFresh avatar May 06 '17 14:05 kitianFresh

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

longhaiqwe avatar Jun 20 '17 01:06 longhaiqwe

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

Yelloboy avatar Oct 04 '17 06:10 Yelloboy

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

thyeun avatar Oct 04 '17 07:10 thyeun

@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 [email protected]

forsunwell avatar May 06 '18 14:05 forsunwell

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 avatar May 06 '18 14:05 ivan-nginx

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.

ivan-nginx avatar May 07 '18 01:05 ivan-nginx

@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!

thyeun avatar May 07 '18 02:05 thyeun

@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.

sli1989 avatar May 08 '18 04:05 sli1989

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

MoBenw avatar Aug 12 '18 17:08 MoBenw

@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

aline2013 avatar Oct 12 '18 08:10 aline2013