Skip to content

Commit

Permalink
docs(zh): sync and tweak translations (#3883)
Browse files Browse the repository at this point in the history
Co-authored-by: Xavi Lee <xavilee2002@outlook.com>
  • Loading branch information
Jinzedev and awxiaoxian2020 committed May 12, 2024
1 parent d5dbd70 commit 9447cee
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 14 deletions.
48 changes: 48 additions & 0 deletions docs/zh/guide/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,51 @@ Cache-Control: max-age=31536000,immutable
### Kinsta 静态站点托管 {#kinsta-static-site-hosting}

你可以按照这些[说明](https://kinsta.com/docs/vitepress-static-site-example/)[Kinsta](https://kinsta.com/static-site-hosting/) 上部署 Vitepress 站点。

### Stormkit

你可以按照这些[说明](https://stormkit.io/blog/how-to-deploy-vitepress)将你的 VitePress 项目部署到 [Stormkit](https://www.stormkit.io)

### Nginx

下面是一个 Nginx 服务器块配置示例。此配置包括对基于文本的常见资源的 gzip 压缩、使用适当缓存头为 VitePress 站点静态文件提供服务的规则以及处理 `cleanUrls: true` 的方法。

```nginx
server {
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
listen 80;
server_name _;
index index.html;
location / {
# content location
root /app;
# exact matches -> reverse clean urls -> folders -> not found
try_files $uri $uri.html $uri/ =404;
# non existent pages
error_page 404 /404.html;
# a folder without index.html raises 403 in this setup
error_page 403 /404.html;
# adjust caching headers
# files in the assets folder have hashes filenames
location ~* ^/assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
}
```

本配置默认已构建的 VitePress 站点位于服务器上的 `/app` 目录中。如果站点文件位于其他位置,请相应调整 `root` 指令。

::: warning 不要默认为 index.html
try_files 解析不能像其他 Vue 应用那样默认为 index.html。这会导致页面状态处于无效。
:::

更多信息请参见 [nginx 官方文档](https://nginx.org/en/docs/)、这些 GitHub Issue [#2837](https://github.com/vuejs/vitepress/discussions/2837)[#3235](https://github.com/vuejs/vitepress/issues/3235)以及 Mehdi Merah 发表的[博客](https://blog.mehdi.cc/articles/vitepress-cleanurls-on-nginx-environment#readings)
2 changes: 1 addition & 1 deletion docs/zh/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ $ bun vitepress init
<<< @/snippets/init.ansi

:::tip Vue 作为 peer dependency
如果打算使用 Vue 组件或 API 进行自定义,还应该明确地将 `vue` 安装为 peer dependency。
如果打算使用 Vue 组件或 API 进行自定义,还应该明确地将 `vue` 安装为 dependency。
:::

## 文件结构 {#file-structure}
Expand Down
31 changes: 18 additions & 13 deletions docs/zh/guide/sitemap-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
VitePress 提供开箱即用的配置,为站点生成 `sitemap.xml` 文件。要启用它,请将以下内容添加到 `.vitepress/config.js` 中:

```ts
import { defineConfig } from 'vitepress'

export default defineConfig({
export default {
sitemap: {
hostname: 'https://example.com'
}
})
}
```

要在 `sitemap.xml` 中包含 `<lastmod>` 标签,可以启用 [`lastUpdated`](../reference/default-theme-last-updated) 选项。
Expand All @@ -19,28 +17,35 @@ export default defineConfig({
VitePress 的 sitemap 由 [`sitemap`](https://www.npmjs.com/package/sitemap) 模块提供支持。可以将该模块支持的选项传递给配置文件中的 `sitemap` 选项。这些选项将直接传递给 `SitemapStream` 构造函数。有关更多详细信息,请参阅 [`sitemap` 文档](https://www.npmjs.com/package/sitemap#options-you-can-pass)。例如:

```ts
import { defineConfig } from 'vitepress'

export default defineConfig({
export default {
sitemap: {
hostname: 'https://example.com',
lastmodDateOnly: false
}
})
}
```

如果在配置中使用 `base`,则应将其追加到 `hostname` 选项中:

```ts
export default {
base: '/my-site/',
sitemap: {
hostname: 'https://example.com/my-site/'
}
}
```

## `transformItems` Hook

在将 sitemap 写入 `sitemap.xml` 文件之前,可以使用 `sitemap.transformItems` 钩子来修改 sitemap。使用 sitemap 调用该钩子,应返回 sitemap 数组。例如:

```ts
import { defineConfig } from 'vitepress'

export default defineConfig({
export default {
sitemap: {
hostname: 'https://example.com',
transformItems: (items) => {
// 添加新选项或修改/过滤现有选项
// 添加新项目或修改/筛选现有选项
items.push({
url: '/extra-page',
changefreq: 'monthly',
Expand All @@ -49,5 +54,5 @@ export default defineConfig({
return items
}
}
})
}
```

0 comments on commit 9447cee

Please sign in to comment.