diff --git a/docs/zh/guide/getting-started.md b/docs/zh/guide/getting-started.md index 6d9303a1..df35b6f9 100644 --- a/docs/zh/guide/getting-started.md +++ b/docs/zh/guide/getting-started.md @@ -2,18 +2,18 @@ ## 在线尝试 {#try-it-online} -You can try VitePress directly in your browser on [StackBlitz](https://vitepress.new). +可以直接在 [StackBlitz](https://vitepress.new) 上进行在线尝试。 ## 安装 {#installation} ### 前置知识 {#prerequisites} -- [Node.js](https://nodejs.org/) version 16 or higher. -- Terminal for accessing VitePress via its command line interface (CLI). -- Text Editor with [Markdown](https://en.wikipedia.org/wiki/Markdown) syntax support. - - [VSCode](https://code.visualstudio.com/) is recommended, along with the [official Vue extension](https://marketplace.visualstudio.com/items?itemName=Vue.volar). +- [Node.js](https://nodejs.org/) 16 及以上版本。 +- 通过命令行界面 (CLI) 访问 VitePress 的终端。 +- 支持 [Markdown](https://en.wikipedia.org/wiki/Markdown) 语法的编辑器。 + - 推荐 [VSCode](https://code.visualstudio.com/) 及其[官方 Vue 扩展](https://marketplace.visualstudio.com/items?itemName=Vue.volar)。 -VitePress can be used on its own, or be installed into an existing project. In both cases, you can install it with: +VitePress 可以单独使用,也可以安装到现有项目中。在这两种情况下,都可以使用以下方式安装它: ::: code-group @@ -31,8 +31,8 @@ $ yarn add -D vitepress ::: -::: details Getting missing peer deps warnings? -If using PNPM, you will notice a missing peer warning for `@docsearch/js`. This does not prevent VitePress from working. If you wish to suppress this warning, add the following to your `package.json`: +::: details 遇到了 missing peer deps 警告? +如果使用 PNPM,会注意到对 `@docsearch/js` 的 missing peer deps 警告。这不会影响 VitePress 运行。如果希望禁止显示此警告,请将以下内容添加到 `package.json`: ```json "pnpm": { @@ -48,7 +48,7 @@ If using PNPM, you will notice a missing peer warning for `@docsearch/js`. This ### 安装向导 {#setup-wizard} -VitePress ships with a command line setup wizard that will help you scaffold a basic project. After installation, start the wizard by running: +VitePress 附带一个命令行设置向导,可以帮助您构建一个基本项目。安装后,通过运行以下命令启动向导: ::: code-group @@ -62,21 +62,21 @@ $ pnpm exec vitepress init ::: -You will be greeted with a few simple questions: +你将需要回答几个简单的问题:

vitepress init screenshot

-:::tip Vue as Peer Dependency -If you intend to perform customization that uses Vue components or APIs, you should also explicitly install `vue` as a peer dependency. +:::tip Vue 作为 +如果打算使用 Vue 组件或 API 进行自定义,还应该明确地将 `vue` 安装为 peer dependency。 ::: ## 文件结构 {#file-structure} -If you are building a standalone VitePress site, you can scaffold the site in your current directory (`./`). However, if you are installing VitePress in an existing project alongside other source code, it is recommended to scaffold the site in a nested directory (e.g. `./docs`) so that it is separate from the rest of the project. +如果你正在构建一个独立的 VitePress 站点,你可以在当前目录 (`./`) 中搭建站点。但是,如果在现有项目中与其他源代码一起安装 VitePress,建议将站点搭建在嵌套目录 (例如 `./docs`) 中,以便它与项目的其余部分分开。 -Assuming you chose to scaffold the VitePress project in `./docs`, the generated file structure should look like this: +假设你选择在 `./docs` 中搭建 VitePress 项目,生成的文件结构应该是这样的: ``` . @@ -89,15 +89,15 @@ Assuming you chose to scaffold the VitePress project in `./docs`, the generated └─ package.json ``` -The `docs` directory is considered the **project root** of the VitePress site. The `.vitepress` directory is a reserved location for VitePress' config file, dev server cache, build output, and optional theme customization code. + `docs` 目录作为 VitePress 站点的项目**根目录**。`.vitepress` 目录是 VitePress 配置文件、开发服务器缓存、构建输出和可选主题自定义代码的位置。 :::tip -By default, VitePress stores its dev server cache in `.vitepress/cache`, and the production build output in `.vitepress/dist`. If using Git, you should add them to your `.gitignore` file. These locations can also be [configured](../reference/site-config#outdir). +默认情况下,VitePress 将其开发服务器缓存存储在 `.vitepress/cache` 中,并将生产构建输出存储在 `.vitepress/dist` 中。如果使用 Git,应该将它们添加到 `.gitignore` 文件中。也可以手动[配置](../reference/site-config#outdir)这些位置。 ::: ### 配置文件 {#the-config-file} -The config file (`.vitepress/config.js`) allows you to customize various aspects of your VitePress site, with the most basic options being the title and description of the site: +配置文件 (`.vitepress/config.js`) 让你能够自定义 VitePress 站点的各个方面,最基本的选项是站点的标题和描述: ```js // .vitepress/config.js @@ -112,19 +112,18 @@ export default { } ``` -You can also configure the behavior of the theme via the `themeConfig` option. Consult the [Config Reference](../reference/site-config) for full details on all config options. - +还可以通过 `themeConfig` 选项配置主题的行为。有关所有配置选项的完整详细信息,请参见[配置参考](../reference/site-config)。 ### 源文件 {#source-files} -Markdown files outside the `.vitepress` directory are considered **source files**. +`.vitepress` 目录之外的 Markdown 文件被视为**源文件**。 -VitePress uses **file-based routing**: each `.md` file is compiled into a corresponding `.html` file with the same path. For example, `index.md` will be compiled into `index.html`, and can be visited at the root path `/` of the resulting VitePress site. +VitePress 使用 **基于文件的路由**:每个 `.md` 文件将在相同的路径被编译成为 `.html` 文件。例如,`index.md` 将会被编译成 `index.html`,可以在生成的 VitePress 站点的根路径 `/` 进行访问。 -VitePress also provides the ability to generate clean URLs, rewrite paths, and dynamically generate pages. These will be covered in the [Routing Guide](./routing). +VitePress 还提供了生成简洁 URL、重写路径和动态生成页面的能力。这些将在[路由指南](./routing)中进行介绍。 ## 运行 {#up-and-running} -The tool should have also injected the following npm scripts to your `package.json` if you allowed it to do so during the setup process: +该工具还应该将以下 npm 脚本注入到 `package.json` 中: ```json { @@ -138,7 +137,7 @@ The tool should have also injected the following npm scripts to your `package.js } ``` -The `docs:dev` script will start a local dev server with instant hot updates. Run it with the following command: +`docs:dev` 脚本将启动具有即时热更新的本地开发服务器。使用以下命令运行它: ::: code-group @@ -156,7 +155,7 @@ $ yarn docs:dev ::: -Instead of npm scripts, you can also invoke VitePress directly with: +除了 npm 脚本,还可以直接调用 VitePress: ::: code-group @@ -170,18 +169,18 @@ $ pnpm exec vitepress dev docs ::: -More command line usage is documented in the [CLI Reference](../reference/cli). +更多的命令行用法请参见 [CLI 参考](../reference/cli)。 -The dev server should be running at `http://localhost:5173`. Visit the URL in your browser to see your new site in action! +开发服务应该会运行在 `http://localhost:5173`上。在浏览器中访问 URL 以查看新站点的运行情况吧! ## 下一步 {#what-s-next} -- To better understand how markdown files are mapped to generated HTML, proceed to the [Routing Guide](./routing). +- 想要进一步了解 Markdown 文件是怎么映射到对应的 HTML,请继续阅读[路由指南](./routing)。 -- To discover more about what you can do on the page, such as writing markdown content or using Vue Component, refer to the "Writing" section of the guide. A great place to start would be to learn about [Markdown Extensions](./markdown). +- 要了解有关可以在页面上执行的操作的更多信息,例如编写 Markdown 内容或使用 Vue 组件,请参见指南的“编写”部分。一个很好的起点是了解 [Markdown 扩展](./markdown)。 -- To explore the features provided by the default documentation theme, check out the [Default Theme Config Reference](../reference/default-theme-config). +- 要探索默认文档主题提供的功能,请查看[默认主题配置参考](../reference/default-theme-config)。 -- If you want to further customize the appearance of your site, explore how to either [Extend the Default Theme](./extending-default-theme) or [Build a Custom Theme](./custom-theme). +- 如果想进一步自定义站点的外观,参见[扩展默认主题](./extending-default-theme)或者[构建自定义主题](./custom-theme)。 -- Once your documentation site takes shape, make sure to read the [Deployment Guide](./deploy). +- 文档成形以后,务必阅读[部署指南](./deploy)。 diff --git a/docs/zh/guide/markdown.md b/docs/zh/guide/markdown.md index ca5c65f5..196073b8 100644 --- a/docs/zh/guide/markdown.md +++ b/docs/zh/guide/markdown.md @@ -1,20 +1,20 @@ # Markdown 扩展 {#markdown-extensions} -VitePress comes with built in Markdown Extensions. +VitePress 带有内置的 Markdown 扩展。 ## 标题锚点 {#header-anchors} -Headers automatically get anchor links applied. Rendering of anchors can be configured using the `markdown.anchor` option. +标题会自动应用锚点。可以使用 `markdown.anchor` 选项配置锚点的渲染。 ## 链接 {#links} -Both internal and external links gets special treatments. +内部和外部链接都会被特殊处理。 ### 内部链接 {#internal-links} -Internal links are converted to router link for SPA navigation. Also, every `index.md` contained in each sub-directory will automatically be converted to `index.html`, with corresponding URL `/`. +内部链接将转换为单页导航的路由链接。此外,子目录中包含的每个 `index.md` 都会自动转换为 `index.html`,并带有相应的 URL `/`。 -For example, given the following directory structure: +例如,给定以下目录结构: ``` . @@ -29,7 +29,7 @@ For example, given the following directory structure: └─ four.md ``` -And providing you are in `foo/one.md`: +假设你现在处于 `foo/one.md` 文件中: ```md [Home](/) @@ -40,20 +40,20 @@ And providing you are in `foo/one.md`: [bar - four](../bar/four.html) ``` -### Page Suffix {#page-suffix} +### 页面后缀 {#page-suffix} -Pages and internal links get generated with the `.html` suffix by default. +默认情况下,生成的页面和内部链接带有 `.html` 后缀。 -### External Links {#external-links} +### 外部链接 {#external-links} -Outbound links automatically get `target="_blank" rel="noreferrer"`: +外部链接带有 `target="_blank" rel="noreferrer"`: - [vuejs.org](https://vuejs.org) - [VitePress on GitHub](https://github.com/vuejs/vitepress) ## Frontmatter {#frontmatter} -[YAML frontmatter](https://jekyllrb.com/docs/front-matter/) is supported out of the box: +[YAML 格式的 frontmatter](https://jekyllrb.com/docs/front-matter/) 开箱即用: ```yaml --- @@ -62,13 +62,13 @@ lang: en-US --- ``` -This data will be available to the rest of the page, along with all custom and theming components. +此数据将可用于页面的其余部分,以及所有自定义和主题组件。 -For more details, see [Frontmatter](../reference/frontmatter-config). +更多信息,参见 [Frontmatter](../reference/frontmatter-config)。 -## GitHub-Style Tables {#github-style-tables} +## GitHub 风格的表格 {#github-style-tables} -**Input** +**输入** ``` | Tables | Are | Cool | @@ -78,7 +78,7 @@ For more details, see [Frontmatter](../reference/frontmatter-config). | zebra stripes | are neat | $1 | ``` -**Output** +**输出** | Tables | Are | Cool | | ------------- | :-----------: | -----: | @@ -86,41 +86,41 @@ For more details, see [Frontmatter](../reference/frontmatter-config). | col 2 is | centered | \$12 | | zebra stripes | are neat | \$1 | -## Emoji :tada: {#emoji-:tada:} +## Emoji :tada: -**Input** +**输入** ``` :tada: :100: ``` -**Output** +**输出** :tada: :100: -A [list of all emojis](https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/full.json) is available. +这里你可以找到[所有支持的 emoji 列表](https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/full.json)。 -## Table of Contents {#table-of-contents} +## 目录表 (TOC) {#table-of-contents} -**Input** +**输入** ``` [[toc]] ``` -**Output** +**输出** [[toc]] -Rendering of the TOC can be configured using the `markdown.toc` option. +可以使用 `markdown.toc` 选项配置 TOC 的呈现效果。 -## Custom Containers {#custom-containers} +## 自定义容器 {#custom-containers} -Custom containers can be defined by their types, titles, and contents. +自定义容器可以通过它们的类型、标题和内容来定义。 -### Default Title {#default-title} +### 默认标题 {#default-title} -**Input** +**输入** ```md ::: info @@ -144,7 +144,7 @@ This is a details block. ::: ``` -**Output** +**输出** ::: info This is an info box. @@ -166,11 +166,11 @@ This is a dangerous warning. This is a details block. ::: -### Custom Title {#custom-title} +### 自定义标题 {#custom-title} -You may set custom title by appending the text right after the "type" of the container. +可以通过在容器的“类型”之后附加文本来设置自定义标题。 -**Input** +**输入** ````md ::: danger STOP @@ -184,7 +184,7 @@ console.log('Hello, VitePress!') ::: ```` -**Output** +**输出** ::: danger STOP Danger zone, do not proceed @@ -196,10 +196,9 @@ console.log('Hello, VitePress!') ``` ::: -### `raw` {#`raw`} - -This is a special container that can be used to prevent style and router conflicts with VitePress. This is especially useful when you're documenting component libraries. You might also wanna check out [whyframe](https://whyframe.dev/docs/integrations/vitepress) for better isolation. +### `raw` +这是一个特殊的容器,可以用来防止与 VitePress 的样式和路由冲突。这在记录组件库时特别有用。你可能还想查看 [whyframe](https://whyframe.dev/docs/integrations/vitepress) 以获得更好的隔离。 **Syntax** ```md @@ -208,17 +207,17 @@ Wraps in a
::: ``` -`vp-raw` class can be directly used on elements too. Style isolation is currently opt-in: +`vp-raw` class 也可以直接用于元素。样式隔离目前是可选的: ::: details -- Install required deps with your preferred package manager: +- 使用你喜欢的包管理器来安装需要的依赖项: ```sh $ npm install -D postcss postcss-prefix-selector ``` -- Create a file named `docs/.postcssrc.cjs` and add this to it: +- 创建 `docs/.postcssrc.cjs` 并将以下内容 ```js module.exports = { @@ -237,11 +236,11 @@ Wraps in a
::: -## Syntax Highlighting in Code Blocks {#syntax-highlighting-in-code-blocks} +## 代码块中的语法高亮 {#syntax-highlighting-in-code-blocks} -VitePress uses [Shiki](https://shiki.matsu.io/) to highlight language syntax in Markdown code blocks, using coloured text. Shiki supports a wide variety of programming languages. All you need to do is append a valid language alias to the beginning backticks for the code block: +VitePress 使用 [Shiki](https://shiki.matsu.io/) 在 Markdown 代码块中使用彩色文本实现语法高亮。Shiki 支持多种编程语言。你需要做的就是将有效的语言别名附加到代码块的开头: -**Input** +**输入** ```` ```js @@ -262,7 +261,7 @@ export default { ``` ```` -**Output** +**输出** ```js export default { @@ -279,13 +278,13 @@ export default { ``` -A [list of valid languages](https://github.com/shikijs/shiki/blob/main/docs/languages.md) is available on Shiki's repository. +在 Shiki 的代码仓库中,可以找到[合法的编程语言列表](https://github.com/shikijs/shiki/blob/main/docs/languages.md)。 -You may also customize syntax highlight theme in app config. Please see [`markdown` options](../reference/site-config#markdown) for more details. +还可以全局配置中自定义语法高亮主题。有关详细信息,参见 [`markdown` 选项](../reference/site-config#markdown)得到更多信息。 -## Line Highlighting in Code Blocks {#line-highlighting-in-code-blocks} +## 在代码块中实现行高亮 {#line-highlighting-in-code-blocks} -**Input** +**输入** ```` ```js{4} @@ -299,7 +298,7 @@ export default { ``` ```` -**Output** +**输出** ```js{4} export default { @@ -311,13 +310,13 @@ export default { } ``` -In addition to a single line, you can also specify multiple single lines, ranges, or both: +除了单行之外,还可以指定多个单行、多行,或两者均指定: -- Line ranges: for example `{5-8}`, `{3-10}`, `{10-17}` -- Multiple single lines: for example `{4,7,9}` -- Line ranges and single lines: for example `{4,7-13,16,23-27,40}` +- 多行:例如 `{5-8}`、`{3-10}`、`{10-17}` +- 多个单行:例如 `{4,7,9}` +- 多行与单行:例如 `{4,7-13,16,23-27,40}` -**Input** +**输入** ```` ```js{1,4,6-8} @@ -335,7 +334,7 @@ export default { // Highlighted ``` ```` -**Output** +**输出** ```js{1,4,6-8} export default { // Highlighted @@ -351,9 +350,9 @@ export default { // Highlighted } ``` -Alternatively, it's possible to highlight directly in the line by using the `// [!code hl]` comment. +也可以使用 `// [!code hl]` 注释实现行高亮。 -**Input** +**输入** ```` ```js @@ -367,7 +366,7 @@ export default { ``` ```` -**Output** +**输出** ```js export default { @@ -379,15 +378,15 @@ export default { } ``` -## Focus in Code Blocks {#focus-in-code-blocks} +## 代码块中聚焦 {#focus-in-code-blocks} -Adding the `// [!code focus]` comment on a line will focus it and blur the other parts of the code. +在某一行上添加 `// [!code focus]` 注释将聚焦它并模糊代码的其他部分。 -Additionally, you can define a number of lines to focus using `// [!code focus:]`. +此外,可以使用 `// [!code focus:]` 定义要聚焦的行数。 -**Input** +**输入** -Note that only one space is required after `!code`, here are two to prevent processing. +`!code` 后面只需要一个空格,为了展示原始的代码而不被实际渲染,这里有两个空格: ```` ```js @@ -401,7 +400,7 @@ export default { ``` ```` -**Output** +**输出** ```js export default { @@ -413,11 +412,11 @@ export default { } ``` -## Colored Diffs in Code Blocks {#colored-diffs-in-code-blocks} +## 代码块中的颜色差异 {#colored-diffs-in-code-blocks} Adding the `// [!code --]` or `// [!code ++]` comments on a line will create a diff of that line, while keeping the colors of the codeblock. -**Input** +**输入** Note that only one space is required after `!code`, here are two to prevent processing. @@ -434,7 +433,7 @@ export default { ``` ```` -**Output** +**输出** ```js export default { @@ -451,7 +450,7 @@ export default { Adding the `// [!code warning]` or `// [!code error]` comments on a line will color it accordingly. -**Input** +**输入** Note that only one space is required after `!code`, here are two to prevent processing. @@ -468,7 +467,7 @@ export default { ``` ```` -**Output** +**输出** ```js export default { @@ -497,7 +496,7 @@ Please see [`markdown` options](../reference/site-config#markdown) for more deta You can add `:line-numbers` / `:no-line-numbers` mark in your fenced code blocks to override the value set in config. -**Input** +**输入** ````md ```ts {1} @@ -513,7 +512,7 @@ const line3 = 'This is line 3' ``` ```` -**Output** +**输出** ```ts {1} // line-numbers is disabled by default @@ -541,7 +540,7 @@ It also supports [line highlighting](#line-highlighting-in-code-blocks): <<< @/filepath{highlightLines} ``` -**Input** +**输入** ```md <<< @/snippets/snippet.js{2} @@ -551,7 +550,7 @@ It also supports [line highlighting](#line-highlighting-in-code-blocks): <<< @/snippets/snippet.js -**Output** +**输出** <<< @/snippets/snippet.js{2} @@ -561,7 +560,7 @@ The value of `@` corresponds to the source root. By default it's the VitePress p You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/codebasics#_folding) to only include the corresponding part of the code file. You can provide a custom region name after a `#` following the filepath: -**Input** +**输入** ```md <<< @/snippets/snippet-with-region.js#snippet{1} @@ -571,7 +570,7 @@ You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/co <<< @/snippets/snippet-with-region.js -**Output** +**输出** <<< @/snippets/snippet-with-region.js#snippet{1} @@ -595,7 +594,7 @@ This is helpful if source language cannot be inferred from your file extension. You can group multiple code blocks like this: -**Input** +**输入** ````md ::: code-group @@ -624,7 +623,7 @@ export default config ::: ```` -**Output** +**输出** ::: code-group @@ -653,7 +652,7 @@ export default config You can also [import snippets](#import-code-snippets) in code groups: -**Input** +**输入** ```md ::: code-group @@ -669,7 +668,7 @@ You can also [import snippets](#import-code-snippets) in code groups: ::: ``` -**Output** +**输出** ::: code-group @@ -683,7 +682,7 @@ You can also [import snippets](#import-code-snippets) in code groups: You can include a markdown file in another markdown file like this: -**Input** +**输入** ```md # Docs {#docs} diff --git a/docs/zh/guide/routing.md b/docs/zh/guide/routing.md index f275fb7e..b742d17e 100644 --- a/docs/zh/guide/routing.md +++ b/docs/zh/guide/routing.md @@ -247,7 +247,7 @@ export default { } ``` -**Output** +**输出** ``` . diff --git a/docs/zh/guide/using-vue.md b/docs/zh/guide/using-vue.md index 08ad01e3..43d0fbe5 100644 --- a/docs/zh/guide/using-vue.md +++ b/docs/zh/guide/using-vue.md @@ -1,46 +1,46 @@ # 在 Markdown 使用 Vue {#using-vue-in-markdown} -In VitePress, each Markdown file is compiled into HTML and then processed as a [Vue Single-File Component](https://vuejs.org/guide/scaling-up/sfc.html). This means you can use any Vue features inside the Markdown, including dynamic templating, using Vue components, or arbitrary in-page Vue component logic by adding a `