Skip to content

Commit 7977532

Browse files
committed
docs($theme-default): refine built-in search and frontmatter
1 parent 01cd096 commit 7977532

File tree

4 files changed

+59
-22
lines changed

4 files changed

+59
-22
lines changed

packages/docs/docs/guide/frontmatter.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ lang = "en-US"
4949

5050
Title of current page.
5151

52-
### tags
53-
54-
- Type: `array`
55-
- Default: `undefined`
56-
57-
You can use tags to improve [built-in search](/theme/default-theme-config.html#built-in-search).
58-
5952
### lang
6053

6154
- Type: `string`
@@ -137,3 +130,17 @@ See: [Default Theme Config > Prev / Next Links](../theme/default-theme-config.md
137130
- Default: `undefined`
138131

139132
See: [Default Theme Config > Prev / Next Links](../theme/default-theme-config.md#prev-next-links).
133+
134+
### search
135+
136+
- Type: `boolean`
137+
- Default: `undefined`
138+
139+
See: [Default Theme Config > Built-in Search](../theme/default-theme-config.html#built-in-search).
140+
141+
### tags
142+
143+
- Type: `array`
144+
- Default: `undefined`
145+
146+
See: [Default Theme Config > Built-in Search](../theme/default-theme-config.html#built-in-search).

packages/docs/docs/theme/default-theme-config.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -349,26 +349,30 @@ module.exports = {
349349
}
350350
```
351351

352-
You can also disable the built-in search box for individual pages with `YAML front matter`:
352+
You can improve the search result by [setting `tags` in frontmatter](../guide/frontmatter.md#tags):
353+
353354
```yaml
354355
---
355-
search: false
356+
tags:
357+
- configuration
358+
- theme
359+
- indexing
356360
---
357361
```
358362

359-
::: tip
360-
Built-in Search only builds index from the title, `h2` and `h3` headers and any tags added with `YAML front matter` as shown below, if you need full text search, you can use [Algolia Search](#algolia-search).
361-
:::
363+
You can also disable the built-in search box for individual pages by [setting `search` in frontmatter](../guide/frontmatter.md#search):
362364

363365
```yaml
364366
---
365-
tags:
366-
- configuration
367-
- theme
368-
- indexing
367+
search: false
369368
---
370369
```
371370

371+
::: tip
372+
Built-in Search only builds index from the title, `h2` and `h3` headers and `tags`.
373+
If you need full text search, you can use [Algolia Search](#algolia-search).
374+
:::
375+
372376
### Algolia Search
373377

374378
The `themeConfig.algolia` option allows you to use [Algolia DocSearch](https://community.algolia.com/docsearch/) to replace the simple built-in search. To enable it, you need to provide at least `apiKey` and `indexName`:

packages/docs/docs/zh/guide/frontmatter.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,39 @@ meta:
107107
- 类型: `boolean`
108108
- 默认值: `undefined`
109109

110-
参考: [默认值 Theme Config > Disable the Navbar](../theme/default-theme-config.md#禁用导航栏).
110+
参考: [默认主题配置 > 禁用导航栏](../theme/default-theme-config.md#禁用导航栏)
111111

112112
### sidebar
113113

114114
- 类型: `boolean|'auto'`
115115
- 默认值: `undefined`
116116

117-
参考: [默认值 Theme Config > Sidebar](../theme/default-theme-config.md#侧边栏).
117+
参考: [默认主题配置 > 侧边栏](../theme/default-theme-config.md#侧边栏)
118118

119119
### prev
120120

121121
- 类型: `boolean|string`
122122
- 默认值: `undefined`
123123

124-
参考: [默认值 Theme Config > Prev / Next Links](../theme/default-theme-config.md#上-下一篇链接).
124+
参考: [默认主题配置 > 上 / 下一篇链接](../theme/default-theme-config.md#上-下一篇链接)
125125

126126
### next
127127

128128
- 类型: `boolean|string`
129129
- 默认值: `undefined`
130130

131-
参考: [默认值 Theme Config > Prev / Next Links](../theme/default-theme-config.md#上-下一篇链接).
131+
参考: [默认主题配置 > 上 / 下一篇链接](../theme/default-theme-config.md#上-下一篇链接)
132+
133+
### search
134+
135+
- 类型: `boolean`
136+
- 默认值: `undefined`
137+
138+
参考: [默认主题配置 > 内置搜索](../theme/default-theme-config.md#内置搜索)
139+
140+
### tags
141+
142+
- 类型: `array`
143+
- 默认值: `undefined`
144+
145+
参考: [默认主题配置 > 内置搜索](../theme/default-theme-config.md#内置搜索)

packages/docs/docs/zh/theme/default-theme-config.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,18 @@ module.exports = {
345345
}
346346
```
347347

348-
你可以通过 `YAML front matter` 来对单独的页面禁用内置的搜索框:
348+
你可以通过[在页面的 frontmatter 中设置 `tags`](../guide/frontmatter.md#tags) 来优化搜索结果:
349+
350+
```yaml
351+
---
352+
tags:
353+
- 配置
354+
- 主题
355+
- 索引
356+
---
357+
```
358+
359+
你可以通过[在页面的 frontmatter 中设置 `search`](../guide/frontmatter.md#search) 来对单独的页面禁用内置的搜索框:
349360

350361
```yaml
351362
---
@@ -354,7 +365,8 @@ search: false
354365
```
355366

356367
::: tip
357-
内置搜索只会为页面的标题、`h2``h3` 构建搜索索引,如果你需要全文搜索,你可以使用 [Algolia 搜索](#Algolia-搜索)
368+
内置搜索只会为页面的标题、`h2``h3` 以及 `tags` 构建搜索索引。
369+
如果你需要全文搜索,你可以使用 [Algolia 搜索](#algolia-搜索)
358370
:::
359371

360372
### Algolia 搜索

0 commit comments

Comments
 (0)