Skip to content

algolia搜索

algolia有两个方式使用:

  1. 自行添加CI脚本, 和crawlerConfig.json爬取数据
  2. 基于官方的DocSearch来爬取数据

方式1

前期准备

  1. 注册algolia账号, 并创建一个应用

  2. 添加crawlerConfig.json, 并添加以下内容:

crawlerConfig.json
json
{
  "index_name": "My First Application",
  "start_urls": ["https://mirwangjn.github.io/Note/"],
  "rateLimit": 8,
  "maxDepth": 10,
  "selectors": {
    "lvl0": {
      "selector": "",
      "defaultValue": "Documentation"
    },
    "lvl1": ".content h1",
    "lvl2": ".content h2",
    "lvl3": ".content h3",
    "lvl4": ".content h4",
    "lvl5": ".content h5",
    "content": ".content p, .content li",
    "lang": {
      "selector": "/html/@lang",
      "type": "xpath",
      "global": true
    }
  },
  "selectors_exclude": [
    "aside",
    ".page-footer",
    ".next-and-prev-link",
    ".table-of-contents"
  ],
  "custom_settings": {
    "attributesForFaceting": ["lang", "tags"]
  },
  "js_render": true
}

Released under the MIT License.