Skip to content

Commit

Permalink
docs($theme-default): refine built-in search and frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Mar 24, 2020
1 parent 01cd096 commit 7977532
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 22 deletions.
21 changes: 14 additions & 7 deletions packages/docs/docs/guide/frontmatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ lang = "en-US"

Title of current page.

### tags

- Type: `array`
- Default: `undefined`

You can use tags to improve [built-in search](/theme/default-theme-config.html#built-in-search).

### lang

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

See: [Default Theme Config > Prev / Next Links](../theme/default-theme-config.md#prev-next-links).

### search

- Type: `boolean`
- Default: `undefined`

See: [Default Theme Config > Built-in Search](../theme/default-theme-config.html#built-in-search).

### tags

- Type: `array`
- Default: `undefined`

See: [Default Theme Config > Built-in Search](../theme/default-theme-config.html#built-in-search).
22 changes: 13 additions & 9 deletions packages/docs/docs/theme/default-theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,26 +349,30 @@ module.exports = {
}
```

You can also disable the built-in search box for individual pages with `YAML front matter`:
You can improve the search result by [setting `tags` in frontmatter](../guide/frontmatter.md#tags):

```yaml
---
search: false
tags:
- configuration
- theme
- indexing
---
```

::: tip
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).
:::
You can also disable the built-in search box for individual pages by [setting `search` in frontmatter](../guide/frontmatter.md#search):

```yaml
---
tags:
- configuration
- theme
- indexing
search: false
---
```

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

### Algolia Search

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`:
Expand Down
22 changes: 18 additions & 4 deletions packages/docs/docs/zh/guide/frontmatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,39 @@ meta:
- 类型: `boolean`
- 默认值: `undefined`

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

### sidebar

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

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

### prev

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

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

### next

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

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

### search

- 类型: `boolean`
- 默认值: `undefined`

参考: [默认主题配置 > 内置搜索](../theme/default-theme-config.md#内置搜索)

### tags

- 类型: `array`
- 默认值: `undefined`

参考: [默认主题配置 > 内置搜索](../theme/default-theme-config.md#内置搜索)
16 changes: 14 additions & 2 deletions packages/docs/docs/zh/theme/default-theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,18 @@ module.exports = {
}
```

你可以通过 `YAML front matter` 来对单独的页面禁用内置的搜索框:
你可以通过[在页面的 frontmatter 中设置 `tags`](../guide/frontmatter.md#tags) 来优化搜索结果:

```yaml
---
tags:
- 配置
- 主题
- 索引
---
```

你可以通过[在页面的 frontmatter 中设置 `search`](../guide/frontmatter.md#search) 来对单独的页面禁用内置的搜索框:

```yaml
---
Expand All @@ -354,7 +365,8 @@ search: false
```

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

### Algolia 搜索
Expand Down

0 comments on commit 7977532

Please sign in to comment.