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

Update algolia search docs with vendors #119

Merged
merged 4 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ calendar:
maxResults: 250

# Algolia Search
# See: https://github.com/theme-next/hexo-theme-next/blob/master/docs/ALGOLIA-SEARCH.md
# Dependencies: https://github.com/theme-next/theme-next-algolia-instant-search
algolia_search:
enable: false
Expand Down
24 changes: 21 additions & 3 deletions docs/ALGOLIA-SEARCH.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">Algolia Search</h1>


NexT provides search plugin for index your hexo website content. To use this feature, make sure that the version of NexT you are using is after the v5.1.0 release. What you should note here is that only turn on `enable` of `algolia_search` in `next/_config.yml` cannot let you use the algolia search correctly, you need to install corresponding [Hexo Algolia](https://github.com/oncletom/hexo-algolia) plugin to seach your website with Algolia. Follow the steps described below to complete the installation of Algolia search.
NexT provides Algolia search plugin for index your hexo website content. To use this feature, make sure that the version of NexT you are using is after the v5.1.0 release. What you should note here is that only turn on `enable` of `algolia_search` in `next/_config.yml` cannot let you use the algolia search correctly, you need to install corresponding [Hexo Algolia](https://github.com/oncletom/hexo-algolia) plugin to seach your website with Algolia. Follow the steps described below to complete the installation of Algolia search.

1. Register at [Algolia](https://www.algolia.com/), you can log in directly using GitHub or Google Account. Upon Customer’s initial sign-up for an Account, Customer will have a free, fourteen (14) day evaluation period (the “Evaluation Period”) for the Algolia Services commencing on the Effective Date, subject to the limitations on Algolia’s website. After that, Algolia offers a free, branded version for up to 10k records and 100k operations per month.

Expand All @@ -12,8 +12,8 @@ NexT provides search plugin for index your hexo website content. To use this fea
1. Algolia requires users to upload their search index data either manually or via provided APIs. Install and configure [Hexo Algolia](https://github.com/oncletom/hexo-algolia) in your Hexo directory. This plugin will index your site and upload selected data to Algolia.

```
cd hexo
npm install --save hexo-algolia
$ cd hexo
$ npm install --save hexo-algolia
```

1. Go to the `API Keys` page and find your credentials. You will need the `Application ID` and the `Search-only API key` in the following sections. The `Admin API key` need to keep confidential. Never store your Admin API Key as apiKey in the` _config.yml` file: it would give full control of your Algolia index to others and you don't want to face the consequences.
Expand Down Expand Up @@ -46,6 +46,24 @@ NexT provides search plugin for index your hexo website content. To use this fea

![](http://theme-next.iissnan.com/uploads/algolia/algolia-step-4.png)

1. Change dir to NexT directory, and install module to `source/lib` directory.

```
$ cd themes/next
$ git clone https://github.com/theme-next/theme-next-algolia-instant-search source/lib/algolia-instant-search
```

If you want to use the CDN instead of clone this repo, then need to **set vendors** in NexT `_config.yml` file:
```yml
vendors:
...
# Internal version: 1
# https://www.algolia.com
algolia_instant_js: https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.js
algolia_instant_css: https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.min.css
...
```

1. In `next/_config.yml`, turn on `enable` of `algolia_search`. You can adjust the text in `labels` according to your needs.

```yml
Expand Down
24 changes: 22 additions & 2 deletions docs/zh-CN/ALGOLIA-SEARCH.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ NexT 内部提供 Algolia 的搜索功能,要使用此功能请确保所使用
1. Index 创建完成后,此时这个 Index 里未包含任何数据。接下来需要安装 [Hexo Algolia](https://github.com/oncletom/hexo-algolia) 扩展,这个扩展的功能是搜集站点的内容并通过 API 发送给 Algolia。前往站点根目录,执行命令安装:

```
npm install --save hexo-algolia
$ cd hexo
$ npm install --save hexo-algolia
```

1. 在 `API Keys` 页面找到需要使用的一些配置的值,包括 `ApplicationID` 和 `Search-Only API Key`。注意,`Admin API Key` 需要保密保存,不要外泄。

![](https://user-images.githubusercontent.com/8521181/35479066-64e35aec-0428-11e8-91f9-1ec3afa45c5c.png)

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

![](https://user-images.githubusercontent.com/8521181/35479064-611aa0b4-0428-11e8-85a1-cfb449b486ec.png)
![](https://user-images.githubusercontent.com/8521181/35479084-d4f7ac02-0428-11e8-95a6-c4e3b1bef47b.png)
Expand All @@ -42,6 +43,25 @@ NexT 内部提供 Algolia 的搜索功能,要使用此功能请确保所使用

![](http://theme-next.iissnan.com/uploads/algolia/algolia-step-4.png)

1. 切换到 NexT 目录,并安装 algolia-instant-search 到 `source/lib` 目录。

```
$ cd themes/next
$ git clone https://github.com/theme-next/theme-next-algolia-instant-search source/lib/algolia-instant-search
```

如果你想直接使用 CDN 设置 Algolia Search,则需要在`主题配置文件`中添加 vendors 字段:

```yml
vendors:
...
# Internal version: 1
# https://www.algolia.com
algolia_instant_js: https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.js
algolia_instant_css: https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.min.css
...
```

1. 更改`主题配置文件`,找到 Algolia Search 配置部分,将 `enable` 改为 `true` 即可,根据需要你可以调整 `labels` 中的文本:

```yml
Expand Down
5 changes: 5 additions & 0 deletions source/css/_common/components/third-party/algolia-search.styl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// fix bug using algolia search's CDN
svg path {
display: none;
}

.algolia-pop-overlay
position: fixed
width: 100%
Expand Down