From 3b860f9e8c25eba821f71dbd417bbf6c52b3e1ca Mon Sep 17 00:00:00 2001 From: Xavi Lee Date: Wed, 24 Jan 2024 15:42:18 +0800 Subject: [PATCH] docs(zh): sync translations (#3493) * sync with https://github.com/vuejs/vitepress/commit/a1fb363a8b6ea2cbf34f8e687aef8bd18ae8ea7c * sync with https://github.com/vuejs/vitepress/commit/9510cd70c14ce9a80962ade5dd1702f7d2e2218e * sync with https://github.com/vuejs/vitepress/commit/c882fa1469a7bd0d6e28196e7a841adf48e803f1 * sync with https://github.com/vuejs/vitepress/commit/ba3c6441be38b0828c67dad35acabab0035fc816 * sync with https://github.com/vuejs/vitepress/commit/ac87d19ca1bbc966e5fe1cca5f433f5ea4b11be3 --- docs/zh/guide/markdown.md | 36 +++++++++++++++++++++++ docs/zh/guide/routing.md | 6 ++-- docs/zh/reference/default-theme-config.md | 1 + docs/zh/reference/site-config.md | 18 ++++++++++++ 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/docs/zh/guide/markdown.md b/docs/zh/guide/markdown.md index f289317c..836d9040 100644 --- a/docs/zh/guide/markdown.md +++ b/docs/zh/guide/markdown.md @@ -263,6 +263,42 @@ Wraps in a
}) ``` +## GitHub 风格的警报 {#github-flavored-alerts} + +VitePress 同样支持以标注的方式渲染 [GitHub 风格的警报](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts)。它们和[自定义容器](#custom-containers)的渲染方式相同。 + +```md +> [!NOTE] +> Highlights information that users should take into account, even when skimming. + +> [!TIP] +> Optional information to help a user be more successful. + +> [!IMPORTANT] +> Crucial information necessary for users to succeed. + +> [!WARNING] +> Critical content demanding immediate user attention due to potential risks. + +> [!CAUTION] +> Negative potential consequences of an action. +``` + +> [!NOTE] +> Highlights information that users should take into account, even when skimming. + +> [!TIP] +> Optional information to help a user be more successful. + +> [!IMPORTANT] +> Crucial information necessary for users to succeed. + +> [!WARNING] +> Critical content demanding immediate user attention due to potential risks. + +> [!CAUTION] +> Negative potential consequences of an action. + ## 代码块中的语法高亮 {#syntax-highlighting-in-code-blocks} VitePress 使用 [Shikiji](https://github.com/antfu/shikiji) ([Shiki](https://shiki.matsu.io/) 的改进版本) 在 Markdown 代码块中使用彩色文本实现语法高亮。Shiki 支持多种编程语言。需要做的就是将有效的语言别名附加到代码块的开头: diff --git a/docs/zh/guide/routing.md b/docs/zh/guide/routing.md index 5f960d14..5df74a44 100644 --- a/docs/zh/guide/routing.md +++ b/docs/zh/guide/routing.md @@ -129,9 +129,9 @@ src/getting-started.md --> /getting-started.html 默认情况下,VitePress 将入站链接解析为以 `.html` 结尾的 URL。但是,一些用户可能更喜欢没有 .html 扩展名的“简洁 URL”——例如,`example.com/path` 而不是 `example.com/path.html`。 -某些服务器或托管平台 (例如 Netlify 或 Vercel) 提供将 `/foo` 之类的 URL 映射到 `/foo.html` (如果存在) 的功能,而无需重定向: +某些服务器或托管平台 (例如 Netlify、Vercel 或 GitHub Pages) 提供将 `/foo` 之类的 URL 映射到 `/foo.html` (如果存在) 的功能,而无需重定向: -- Netlify 默认支持。 +- Netlify 和 GitHub Pages 是默认支持的。 - Vercel 需要在 [vercel.json 中启用 cleanUrls 选项](https://vercel.com/docs/concepts/projects/project-configuration#cleanurls)。 如果可以使用此功能,还可以启用 VitePress 自己的 [`cleanUrls`](../reference/site-config#cleanurls) 配置选项,以便: @@ -139,7 +139,7 @@ src/getting-started.md --> /getting-started.html - 页面之间的入站链接是在没有 `.html` 扩展名的情况下生成的。 - 如果当前路径以 `.html` 结尾,路由器将执行客户端重定向到无扩展路径。 -但是,如果无法为服务器配置此类支持 (例如 GitHub Pages),则必须手动采用以下目录结构: +但是,如果无法为服务器配置此类支持,则必须手动采用以下目录结构: ``` . diff --git a/docs/zh/reference/default-theme-config.md b/docs/zh/reference/default-theme-config.md index 70ac731a..bf8a3e69 100644 --- a/docs/zh/reference/default-theme-config.md +++ b/docs/zh/reference/default-theme-config.md @@ -244,6 +244,7 @@ type SocialLinkIcon = | 'instagram' | 'linkedin' | 'mastodon' + | 'npm' | 'slack' | 'twitter' | 'x' diff --git a/docs/zh/reference/site-config.md b/docs/zh/reference/site-config.md index a2814a95..ef412d98 100644 --- a/docs/zh/reference/site-config.md +++ b/docs/zh/reference/site-config.md @@ -645,6 +645,24 @@ export default { } ``` +#### 示例:添加 canonical URL `` {#example-adding-a-canonical-url-link} + +```ts +export default { + transformPageData(pageData) { + const canonicalUrl = `https://example.com/${pageData.relativePath}` + .replace(/index\.md$/, '') + .replace(/\.md$/, '.html') + + pageData.frontmatter.head ??= [] + pageData.frontmatter.head.push([ + 'link', + { rel: 'canonical', href: canonicalUrl } + ]) + } +} +``` + ### transformHtml - 类型:`(code: string, id: string, context: TransformContext) => Awaitable`