fi3ework / hexo-theme-archer

🎯 A smart and modern theme for Hexo.
https://fi3ework.github.io/hexo-theme-archer
MIT License
1.49k stars 274 forks source link

[请求帮助]无法按教程设置 启用 Algolia 搜索 #304

Closed ted423 closed 2 years ago

ted423 commented 2 years ago

「描述遇到的问题」或「发现的 bug」(Describe the problem or bug you encounter)

你是否已经阅读过以下内容,并确认你的行为是正确的,在 [ ] 中填入 x 选中(Ensure that you had consulted followings and confirm the validity of your operation, fill x in [ ] to select)

如何复现(To Reproduce)

存在问题或 bug 的已部署上线的页面地址(A deployed page link that with bug or problem)

如果可能是与 markdown 内容相关的问题或 bug,请粘贴对应的 markdown 内容(If the problem or bug that may be related to markdown, paste it here)

打开控制台,填写控制台中打印的主题的版本,如果脚本出错可直接提供控制台截图(Open the console and report the version of hexo-theme-archer. You can paste the screenshot on console directly if there is error with script)

信息 (please complete the following information):

其他信息(Additional context) 我把issue里带 Algolia 的都看了,似乎只有我遇到问题(带的参考连接挂了)

首先建了index之后下一步会有建records,由于看不懂我就跳过了,看起来教程没写应该不用做(不过后面我去乱写过了步骤似乎没什么改变)

还看了这里 https://jobbym.github.io/2017/01/16/Hexo%E9%9B%86%E6%88%90Algolia%E6%90%9C%E7%B4%A2%E6%8F%92%E4%BB%B6/ 但是写的还不一样

点击ALL API KEYS 找到新建INDEX对应的key, 编辑权限,在弹出框中找到ACL选择勾选Add records, Delete records, List indices, Delete index权限,点击update更新。

这一步,我找的没有records相关项,所以我把看起来相关的加了,还加了recommendation 包含search、addObject、deleteIndex、listIndexes(后来加了所有的都没用)

如更前面的教程所说 需要记 Search-Only API Key、 Admin API Key。但教程里似乎就没说这两个key要怎么用

然后_config的替换,应该指的上面创建的key?

这时候又新建一个key 这个能加的权限我倒是都能看到,不过windows set之后开始跑是报

ERROR [hexo-algolia] Invalid Application-ID or API key
ERROR >> You might have used an Admin Key or an invalid Key.
ERROR >> Read https://npmjs.com/hexo-algolia#security-concerns for more informations.
ted423 commented 2 years ago

今早跑了下不知道为啥行了(可能npm装完后要hexo deploy一遍?) https://github.com/oncletom/hexo-algolia 看了这里的文档 第一个api key是search only的,应该不用建key,也不用admin 的key

然后第二个set是用的创建的key ,不过应该是Algolia有更新,所以addrecord 和delrecord被别的替代了

ted423 commented 2 years ago

就是好像搜不到东西..

ted423 commented 2 years ago

又试了下,搜不到东西看请求是因为提示{"message":"indexName is not valid","status":400} 肯能因为我在里面有“.”有关 其二是之前的报错可能是因为生成key需要时间,新生成的key有报错。 大概要等

ted423 commented 2 years ago

创建的key不能是locale key

ted423 commented 2 years ago

records里要自己设置好可搜索项

LolipopJ commented 2 years ago

{"message":"indexName is not valid","status":400}

看上去有可能是您在 Hexo 主题目录下配置的 _config.yml 中的 indexName 有问题,此项为您创建的 algolia 搜索中 Indices 的名称:

# _config.yml
algolia:
  applicationID: ***
  apiKey: ***
  indexName: lolipopJ.github.io

您可以在 algolia 控制面板左侧找到您创建的 Indices,填入对应的名字即可。

ted423 commented 2 years ago

{"message":"indexName is not valid","status":400}

看上去有可能是您在 Hexo 主题目录下配置的 _config.yml 中的 indexName 有问题,此项为您创建的 algolia 搜索中 Indices 的名称:

# _config.yml
algolia:
  applicationID: ***
  apiKey: ***
  indexName: lolipopJ.github.io

您可以在 algolia 控制面板左侧找到您创建的 Indices,填入对应的名字即可。

解决了,因为我是在新标签页打开。应该直接在console里看response 主要是搜索没结果,搜索设置那里是我自己加的。当时没搞懂record那要怎么弄,就自己随便加了一条,搜name

然后成功传了record之后还在那搜name,结果自然啥都搜不到

LolipopJ commented 2 years ago

😄 nice.

我也更新了一下本仓库 Wiki 上边语义可能产生误解的地方。我将关闭此 Issue. 😁

ted423 commented 2 years ago

😄 nice.

我也更新了一下本仓库 Wiki 上边语义可能产生误解的地方。我将关闭此 Issue. 😁

试了一下,可以把那个set设到 环境变量 的 用户变量里,这样就不用每次跑都set,理论linux应该也有类似的 .bashrc?

LolipopJ commented 2 years ago

😄 nice.

我也更新了一下本仓库 Wiki 上边语义可能产生误解的地方。我将关闭此 Issue. 😁

试了一下,可以把那个set设到 环境变量 的 用户变量里,这样就不用每次跑都set,理论linux应该也有类似的 .bashrc?

我是用的 Github Actions,把 algolia 的环境变量放到仓库的 secret 里,自动部署的时候配置调用此变量就可以了。

ted423 commented 2 years ago

😄 nice. 我也更新了一下本仓库 Wiki 上边语义可能产生误解的地方。我将关闭此 Issue. 😁

试了一下,可以把那个set设到 环境变量 的 用户变量里,这样就不用每次跑都set,理论linux应该也有类似的 .bashrc?

我是用的 Github Actions,把 algolia 的环境变量放到仓库的 secret 里,自动部署的时候配置调用此变量就可以了。

了解,太菜,还没研究过这块

LolipopJ commented 2 years ago

Okay, 我更新了关于在这里使用 Github Actions 的文档!可以用做参考!