Skip to content

Commit

Permalink
docs(plugin-docsearch): add example crawler config
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Apr 8, 2021
1 parent 374ae43 commit 0294b7a
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/reference/plugin/docsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,43 @@ You need to [submit the URL of your site](https://docsearch.algolia.com/apply/)

Alternatively, you can [run your own crawler](https://docsearch.algolia.com/docs/run-your-own/) to generate the index, and then use your own [appId](#appId), [apiKey](#apikey) and [indexName](#indexname) to configure this plugin.

::: details Click to show the example crawler config
```json{19-23,25-27}
{
"index_name": "your_index_name",
"start_urls": [
"https://your.domain.name/"
],
"stop_urls": [],
"selectors": {
"lvl0": {
"selector": "p.sidebar-heading.active",
"global": true,
"default_value": "Documentation"
},
"lvl1": ".theme-default-content h1",
"lvl2": ".theme-default-content h2",
"lvl3": ".theme-default-content h3",
"lvl4": ".theme-default-content h4",
"lvl5": ".theme-default-content h5",
"text": ".theme-default-content p, .theme-default-content li",
"lang": {
"selector": "/html/@lang",
"type": "xpath",
"global": true
}
},
"custom_settings": {
"attributesForFaceting": ["lang"]
}
}
```

The above `selectors` is the configuration used for the default theme. You can modify them according to the theme you are using.

Notice that the `selectors.lang` and the `custom_settings.attributesForFaceting` fields are **required** to make this plugin work properly.
:::

## Options

### apiKey
Expand Down
37 changes: 37 additions & 0 deletions docs/zh/reference/plugin/docsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,43 @@

或者,你也可以 [运行你自己的爬虫](https://docsearch.algolia.com/docs/run-your-own/) 来创建索引,然后使用你自己的 [appId](#appId), [apiKey](#apikey)[indexName](#indexname) 来配置该插件。

::: details 点击查看爬虫配置示例
```json{19-23,25-27}
{
"index_name": "your_index_name",
"start_urls": [
"https://your.domain.name/"
],
"stop_urls": [],
"selectors": {
"lvl0": {
"selector": "p.sidebar-heading.active",
"global": true,
"default_value": "Documentation"
},
"lvl1": ".theme-default-content h1",
"lvl2": ".theme-default-content h2",
"lvl3": ".theme-default-content h3",
"lvl4": ".theme-default-content h4",
"lvl5": ".theme-default-content h5",
"text": ".theme-default-content p, .theme-default-content li",
"lang": {
"selector": "/html/@lang",
"type": "xpath",
"global": true
}
},
"custom_settings": {
"attributesForFaceting": ["lang"]
}
}
```

上述 `selectors` 是用于默认主题的配置,你可以根据你使用的主题来修改它们。

注意 `selectors.lang``custom_settings.attributesForFaceting` 字段,它们是**必须**的,否则该插件将无法正常工作。
:::

## 配置项

### apiKey
Expand Down

0 comments on commit 0294b7a

Please sign in to comment.