update
pull/1593/head
Xavi Lee 4 years ago
parent 80c588e24a
commit 9ff212508a

@ -1,4 +1,4 @@
# 应用全局配置 {#app-configs}
# 应用全局配置 {#app-config}
应用全局配置是定义站点的全局配置的地方。应用全局配置不仅限于主题配置,还有如“根目录”的配置,或站点的“标题”设置。
@ -115,7 +115,7 @@ export default {
- 类型:`boolean`
- 默认值:`false`
使用 git commit 来获取时间戳。该选项使默认主题显示页面的最后更新时间。你可以通过 [`themeConfig.lastUpdatedText`](theme-configs#lastupdatedtext) 选项来自定义文本。
使用 git commit 来获取时间戳。该选项使默认主题显示页面的最后更新时间。你可以通过 [`themeConfig.lastUpdatedText`](theme-config#lastupdatedtext) 选项来自定义文本。
```ts
export default {

@ -1,4 +1,4 @@
# Frontmatter 配置 {#frontmatter-configs}
# Frontmatter 配置 {#frontmatter-config}
Frontmatter 支持基于页面的配置。在每个标签上,你可以自由地添加任何设置来覆盖任何全局应用或主题配置。此外,还有一些配置,你只能在 Frontmatter 中定义。
@ -19,7 +19,7 @@ editLink: true
- Type: `string`
页面的标题。它与 [config.title](../config/app-configs#title) 相同,并覆盖了应用全局配置。
页面的标题。它与 [config.title](../config/app-config#title) 相同,并覆盖了应用全局配置。
```yaml
---
@ -31,7 +31,7 @@ title: VitePress
- Type: `string | boolean`
标题的后缀。它与 [config.titleTemplate](../config/app-configs#titletemplate) 相同,并覆盖了应用全局配置。
标题的后缀。它与 [config.titleTemplate](../config/app-config#titletemplate) 相同,并覆盖了应用全局配置。
```yaml
---
@ -44,7 +44,7 @@ titleTemplate: Vite & Vue powered static site generator
- Type: `string`
页面的描述。它与 [config.description](../config/app-configs#description) 相同,并覆盖了应用全局配置。
页面的描述。它与 [config.description](../config/app-config#description) 相同,并覆盖了应用全局配置。
```yaml
---
@ -189,4 +189,4 @@ aside: false
- Type: `number | [number, number] | 'deep' | false`
- Default: `2`
The levels of header in the outline to display for the page. It's same as [config.themeConfig.outline](../config/theme-configs#outline), and it overrides the theme config.
The levels of header in the outline to display for the page. It's same as [config.themeConfig.outline](../config/theme-config#outline), and it overrides the theme config.

@ -15,9 +15,9 @@
你也可以使用任意的 `.ts`、`.cjs`、`.mjs`、`.cts` 和 `.mts` 作为配置文件的扩展名。
:::
VitePress 带有 2 种类型的配置。一种是[应用全局配置](./app-configs),它配置站点的基本功能,例如设置站点的标题,或自定义 Markdown 解析器的工作方式。其次是[主题配置](./theme-configs),用于配置站点的主题,例如添加侧边栏,或者添加“在 GitHub 上编辑此页面”链接等功能。
VitePress 带有 2 种类型的配置。一种是[应用全局配置](./app-config),它配置站点的基本功能,例如设置站点的标题,或自定义 Markdown 解析器的工作方式。其次是[主题配置](./theme-config),用于配置站点的主题,例如添加侧边栏,或者添加“在 GitHub 上编辑此页面”链接等功能。
你还可以在 [Frontmatter](./frontmatter-configs) 中进行另一种配置。Frontmatter 配置可以覆盖在该特定页面的应用全局配置或主题配置上定义的全局配置。但是,有几个选项也仅在 frontmatter 中可用。
你还可以在 [Frontmatter](./frontmatter-config) 中进行另一种配置。Frontmatter 配置可以覆盖在该特定页面的应用全局配置或主题配置上定义的全局配置。但是,有几个选项也仅在 frontmatter 中可用。
请参阅相应的配置页面以了解更多信息。

@ -1,4 +1,4 @@
# 主题配置 {#theme-configs}
# 主题配置 {#theme-config}
主题配置可让你自定义主题。你可以通过将 `themeConfig` 键添加到配置文件来定义主题配置。
@ -143,6 +143,11 @@ interface SidebarItem {
}
```
## aside
- Type: `boolean`
- Default: `true`
Setting this value to `false` prevents rendering of aside container.
## outline
- 类型:`number | [number, number] | 'deep' | false`
@ -150,6 +155,11 @@ interface SidebarItem {
纲要中显示的标题的级别。你可以通过传递一个数字来指定一个特定的级别,也可以通过传递一个包含底限和上限的元组来提供一个级别范围。当传递等于 `[2, 6]``'deep'` 时,除了 `h1` 之外,所有的标题级别都显示在大纲中。可以设置 `false` 来隐藏轮廓。
## outlineBadges
- Type: `boolean`
- Default: `true`
By default the badge text is displayed in the outline. Disable this to hide badge text from outline.
## outlineTitle
- 类型:`string`
@ -271,9 +281,23 @@ export default {
}
```
## algolia
- Type: `AlgoliaSearch`
An option to support searching your docs site using [Algolia DocSearch](https://docsearch.algolia.com/docs/what-is-docsearch). Learn more in [Theme: Search](../guide/theme-search)
```ts
export interface AlgoliaSearchOptions extends DocSearchProps {
locales?: Record<string, Partial<DocSearchProps>>
}
```
View full options [here](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts).
## carbonAds
- 类型:`CarbonAds`
- 类型:`CarbonAdsOptions`
显示 [Carbon Ads](https://www.carbonads.net/) 的选项。
@ -289,7 +313,7 @@ export default {
```
```ts
export interface CarbonAds {
export interface CarbonAdsOptions {
code: string
placement: string
}
@ -320,3 +344,24 @@ export interface DocFooter {
next?: string
}
```
## darkModeSwitchLabel
- Type: `string`
- Default: `Appearance`
Can be used to customize the dark mode switch label. This label is only displayed in the mobile view.
## sidebarMenuLabel
- Type: `string`
- Default: `Menu`
Can be used to customize the sidebar menu label. This label is only displayed in the mobile view.
## returnToTopLabel
- Type: `string`
- Default: `Return to top`
Can be used to customize the label of the returnToTop. This label is only displayed in the mobile view.

@ -66,7 +66,7 @@ interface Router {
- **Type**: `(path: string) => string`
将配置的 [`base`](../config/app-configs#base) 添加到给定的 URL 路径。另请参阅 [Base URL](./asset-handling#base-url)。
将配置的 [`base`](../config/app-config#base) 添加到给定的 URL 路径。另请参阅 [Base URL](./asset-handling#base-url)。
## `<Content />`

@ -17,7 +17,7 @@
::: tip 提示
如果使用子目录(`https://example.com/subdir/`)作为部署站点,则必须在 `docs/.vitepress/config.js` 中将 `'/subdir/'` 设置为 [`base`](../config/app-configs#base) 的值。
如果使用子目录(`https://example.com/subdir/`)作为部署站点,则必须在 `docs/.vitepress/config.js` 中将 `'/subdir/'` 设置为 [`base`](../config/app-config#base) 的值。
**示例:** 如果你使用 Github (或 GitLab) 页面并部署到 `user.github.io/repo/`,则将 `base` 设置为 `/repo/`
@ -73,34 +73,35 @@
```yaml
name: Deploy
on:
workflow_dispatch: {}
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
- run: yarn install --frozen-lockfile
- name: Build
run: yarn docs:build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
- uses: actions/configure-pages@v2
- uses: actions/upload-pages-artifact@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/.vitepress/dist
# cname: example.com # if wanna deploy to custom domain
path: docs/.vitepress/dist
- name: Deploy
id: deployment
uses: actions/deploy-pages@v1
```
::: tip 提示
@ -137,6 +138,25 @@
- main
```
4. Alternatively, if you want to use an _alpine_ version of node, you have to install `git` manually. In that case, the code above modifies to this:
```yaml
image: node:16-alpine
pages:
cache:
paths:
- node_modules/
before_script:
- apk add git
script:
- yarn install
- yarn docs:build
artifacts:
paths:
- public
only:
- main
```
## Azure Static Web Apps
1. 参照[官方文档](https://docs.microsoft.com/en-us/azure/static-web-apps/build-configuration)。
@ -198,6 +218,6 @@
}
```
## Layer0
## Edgio
参考[在 Layer0 里创建和部署 VitePress 应用](https://docs.layer0.co/guides/vitepress)。
参考[在 Edgio 里创建和部署 VitePress 应用](https://docs.edg.io/guides/vitepress)。

@ -9,7 +9,7 @@ editLink: true
---
```
在三点虚线之间,你可以设置[预定义变量](../config/frontmatter-configs),甚至可以创建自己的自定义变量。 这些变量可以通过特殊的 <code>$frontmatter</code> 变量来使用。
在三点虚线之间,你可以设置[预定义变量](../config/frontmatter-config),甚至可以创建自己的自定义变量。 这些变量可以通过特殊的 <code>$frontmatter</code> 变量来使用。
这是如何在 Markdown 文件中使用的例子:

@ -12,24 +12,49 @@ VitePress 目前处于 `alpha` 状态。它已经适合开箱即用地组织文
创建并进入新项目的目录。
```sh
$ mkdir vitepress-starter && cd vitepress-starter
```
用你喜欢的包管理工具初始化项目。
```sh
::: code-group
```sh [npm]
$ npm init
```
```sh [yarn]
$ yarn init
```
```sh [pnpm]
$ pnpm init
```
:::
## 步骤 2安装 VitePress {#step-2-install-vitepress}
添加 VitePress 和 Vue 作为项目的开发依赖项。
```sh
$ yarn add --dev vitepress vue
::: code-group
```sh [npm]
$ npm install -D vitepress vue
```
```sh [yarn]
$ yarn add -D vitepress vue
```
```sh [pnpm]
$ pnpm add -D vitepress vue
```
:::
::: details 得到了 peer dependencies 警告?
`@docsearch/js` 的 peer dependencies 存在某些问题。如果你看到某些命令由于它们而失败,你现在可以尝试以下解决方案:
@ -71,10 +96,22 @@ $ mkdir docs && echo '# Hello VitePress' > docs/index.md
在本地启动文档服务。
```sh
::: code-group
```sh [npm]
$ npm run docs:dev
```
```sh [yarn]
$ yarn docs:dev
```
```sh [pnpm]
$ pnpm run docs:dev
```
:::
VitePress 将在 `http://localhost:5173` 启动一个支持热部署的本地开发服务环境。
## 步骤 4添加更多文档 {#step-4-add-more-pages}

@ -281,7 +281,7 @@ export default {
在 Shiki 的仓库里有对应支持的[语言列表](https://github.com/shikijs/shiki/blob/main/docs/languages.md)。
你还可以在应用全局配置中自定义语法高亮主题。有关详细信息,请参阅 [`markdown` 选项](../config/app-configs#markdown)。
你还可以在应用全局配置中自定义语法高亮主题。有关详细信息,请参阅 [`markdown` 选项](../config/app-config#markdown)。
## 代码块中定义行高亮 {#line-highlighting-in-code-blocks}
@ -487,7 +487,7 @@ export default {
}
```
可以通过 [`markdown` 选项](../config/app-configs#markdown)了解更多。
可以通过 [`markdown` 选项](../config/app-config#markdown)了解更多。
## 导入代码片段 {#import-code-snippets}
@ -548,6 +548,34 @@ export default {
这在无法从文件扩展名中推断出源语言会很有用。
You can also [import snippets](#import-code-snippets) in code groups:
**Input**
```md
::: code-group
<!-- filename is used as title by default -->
<<< @/snippets/snippet.js
<!-- you can provide a custom one too -->
<<< @/snippets/snippet-with-region.js#snippet{1,2 ts:line-numbers} [snippet with region]
:::
```
**Output**
::: code-group
<<< @/snippets/snippet.js
<<< @/snippets/snippet-with-region.js#snippet{1,2 ts:line-numbers} [snippet with region]
:::
## 包含其他 Markdown 文件 {#markdown-file-inclusion}
你可以通过下面的写法在 markdown 文件中引入其他的markdown 文件:
@ -617,4 +645,4 @@ module.exports = {
}
```
通过[配置:应用全局配置](../config/app-configs#markdown)查看可配置属性的完整列表。
通过[配置:应用全局配置](../config/app-config#markdown)查看可配置属性的完整列表。

@ -20,4 +20,4 @@
## Frontmatter 配置 {#frontmatter-config}
- `home: true` 选项已更改为 `layout: home`。此外,还修改了许多与主页相关的设置以提供附加功能。详情请参阅[主页指南](./theme-home-page)。
- `footer` 选项移至 [`themeConfig.footer`](../config/theme-configs#footer)。
- `footer` 选项移至 [`themeConfig.footer`](../config/theme-config#footer)。

@ -49,7 +49,7 @@ docs/index.md -> /
docs/getting-started.md -> /getting-started.html
```
你也可以在配置文件中通过 [srcDir](/config/app-configs#srcdir) 选项自定义根目录。使用以下设置运行 `vitepress dev`,与运行 `vitepress dev docs` 命令的效果相同。
你也可以在配置文件中通过 [srcDir](/config/app-config#srcdir) 选项自定义根目录。使用以下设置运行 `vitepress dev`,与运行 `vitepress dev docs` 命令的效果相同。
```ts
export default {
@ -88,7 +88,7 @@ export default {
└─ index.md
```
然而,你也可以通过设置 [`cleanUrls`](/config/app-configs#cleanurls) 选项生成一个简洁的URL。
然而,你也可以通过设置 [`cleanUrls`](/config/app-config#cleanurls) 选项生成一个简洁的URL。
```ts
export default {
@ -120,13 +120,13 @@ packages/pkg-a/src/pkg-a-code.md -> /pkg-a/pkg-a-code.md
packages/pkg-b/src/pkg-b-code.md -> /pkg-b/pkg-b-code.md
```
可以像这样通过 [`rewrites`](/config/app-configs#rewrites) 选项配置映射。
可以像这样通过 [`rewrites`](/config/app-config#rewrites) 选项配置映射。
```ts
export default {
rewrites: {
'packages/pkg-a/src/pkg-a-code.md': 'pkg-a/pkg-a-code',
'packages/pkg-b/src/pkg-b-code.md': 'pkg-b/pkg-b-code'
'packages/pkg-a/src/pkg-a-code.md': 'pkg-a/pkg-a-code.md',
'packages/pkg-b/src/pkg-b-code.md': 'pkg-b/pkg-b-code.md'
}
}
```
@ -156,8 +156,8 @@ export default {
上述内容将创建如下映射。
```
packages/pkg-a/src/pkg-a-code.md -> /pkg-a/pkg-a-code
packages/pkg-b/src/folder/file.md -> /pkg-b/folder/file
packages/pkg-a/src/pkg-a-code.md -> /pkg-a/pkg-a-code.md
packages/pkg-b/src/folder/file.md -> /pkg-b/folder/file.md
```
::: warning 你需要在添加页面时重新启动服务器

@ -4,7 +4,7 @@ Nav 是显示在页面顶部的导航栏。 它包含站点标题、全局菜单
## 站点的标题和 logo {#site-title-and-logo}
默认情况下,导航的展示会引用 [`config.title`](../config/app-configs#title) 配置的站点标题。如果想更改导航上显示的内容,可以在 `themeConfig.siteTitle` 选项中定义自定义文本。
默认情况下,导航的展示会引用 [`config.title`](../config/app-config#title) 配置的站点标题。如果想更改导航上显示的内容,可以在 `themeConfig.siteTitle` 选项中定义自定义文本。
```js
export default {
@ -35,7 +35,7 @@ export default {
}
```
如果你想添加 alt 属性或根据黑暗/光明模式定制它,你也可以传递一个对象作为 logo。详情请参见 [`themeConfig.logo`](../config/theme-configs#logo)。
如果你想添加 alt 属性或根据黑暗/光明模式定制它,你也可以传递一个对象作为 logo。详情请参见 [`themeConfig.logo`](../config/theme-config#logo)。
## 导航链接 {#navigation-links}
@ -46,7 +46,7 @@ export default {
themeConfig: {
nav: [
{ text: 'Guide', link: '/guide' },
{ text: 'Configs', link: '/configs' },
{ text: 'config', link: '/config' },
{ text: 'Changelog', link: 'https://github.com/...' }
]
}
@ -140,4 +140,4 @@ export default {
## 社交链接 {#social-links}
点击这里查看支持的 [`socialLinks`](../config/theme-configs#sociallinks).
点击这里查看支持的 [`socialLinks`](../config/theme-config#sociallinks).

@ -207,7 +207,7 @@ interface TeamMember {
// Social links. e.g. GitHub, Twitter, etc. You may pass in
// the Social Links object here.
// See: https://vitepress.vuejs.org/config/theme-configs.html#sociallinks
// See: https://vitepress.vuejs.org/config/theme-config.html#sociallinks
links?: SocialLink[]
// URL for the sponsor page for the member.

Loading…
Cancel
Save