Skip to content

Commit 0294b7a

Browse files
committed
docs(plugin-docsearch): add example crawler config
1 parent 374ae43 commit 0294b7a

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

docs/reference/plugin/docsearch.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,43 @@ You need to [submit the URL of your site](https://docsearch.algolia.com/apply/)
1616

1717
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.
1818

19+
::: details Click to show the example crawler config
20+
```json{19-23,25-27}
21+
{
22+
"index_name": "your_index_name",
23+
"start_urls": [
24+
"https://your.domain.name/"
25+
],
26+
"stop_urls": [],
27+
"selectors": {
28+
"lvl0": {
29+
"selector": "p.sidebar-heading.active",
30+
"global": true,
31+
"default_value": "Documentation"
32+
},
33+
"lvl1": ".theme-default-content h1",
34+
"lvl2": ".theme-default-content h2",
35+
"lvl3": ".theme-default-content h3",
36+
"lvl4": ".theme-default-content h4",
37+
"lvl5": ".theme-default-content h5",
38+
"text": ".theme-default-content p, .theme-default-content li",
39+
"lang": {
40+
"selector": "/html/@lang",
41+
"type": "xpath",
42+
"global": true
43+
}
44+
},
45+
"custom_settings": {
46+
"attributesForFaceting": ["lang"]
47+
}
48+
}
49+
```
50+
51+
The above `selectors` is the configuration used for the default theme. You can modify them according to the theme you are using.
52+
53+
Notice that the `selectors.lang` and the `custom_settings.attributesForFaceting` fields are **required** to make this plugin work properly.
54+
:::
55+
1956
## Options
2057

2158
### apiKey

docs/zh/reference/plugin/docsearch.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,43 @@
1616

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

19+
::: details 点击查看爬虫配置示例
20+
```json{19-23,25-27}
21+
{
22+
"index_name": "your_index_name",
23+
"start_urls": [
24+
"https://your.domain.name/"
25+
],
26+
"stop_urls": [],
27+
"selectors": {
28+
"lvl0": {
29+
"selector": "p.sidebar-heading.active",
30+
"global": true,
31+
"default_value": "Documentation"
32+
},
33+
"lvl1": ".theme-default-content h1",
34+
"lvl2": ".theme-default-content h2",
35+
"lvl3": ".theme-default-content h3",
36+
"lvl4": ".theme-default-content h4",
37+
"lvl5": ".theme-default-content h5",
38+
"text": ".theme-default-content p, .theme-default-content li",
39+
"lang": {
40+
"selector": "/html/@lang",
41+
"type": "xpath",
42+
"global": true
43+
}
44+
},
45+
"custom_settings": {
46+
"attributesForFaceting": ["lang"]
47+
}
48+
}
49+
```
50+
51+
上述 `selectors` 是用于默认主题的配置,你可以根据你使用的主题来修改它们。
52+
53+
注意 `selectors.lang``custom_settings.attributesForFaceting` 字段,它们是**必须**的,否则该插件将无法正常工作。
54+
:::
55+
1956
## 配置项
2057

2158
### apiKey

0 commit comments

Comments
 (0)