Skip to content

Commit 9447cee

Browse files
docs(zh): sync and tweak translations (#3883)
Co-authored-by: Xavi Lee <[email protected]>
1 parent d5dbd70 commit 9447cee

File tree

3 files changed

+67
-14
lines changed

3 files changed

+67
-14
lines changed

Diff for: docs/zh/guide/deploy.md

+48
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,51 @@ Cache-Control: max-age=31536000,immutable
287287
### Kinsta 静态站点托管 {#kinsta-static-site-hosting}
288288

289289
你可以按照这些[说明](https://kinsta.com/docs/vitepress-static-site-example/) 在 [Kinsta](https://kinsta.com/static-site-hosting/) 上部署 Vitepress 站点。
290+
291+
### Stormkit
292+
293+
你可以按照这些[说明](https://stormkit.io/blog/how-to-deploy-vitepress)将你的 VitePress 项目部署到 [Stormkit](https://www.stormkit.io)。
294+
295+
### Nginx
296+
297+
下面是一个 Nginx 服务器块配置示例。此配置包括对基于文本的常见资源的 gzip 压缩、使用适当缓存头为 VitePress 站点静态文件提供服务的规则以及处理 `cleanUrls: true` 的方法。
298+
299+
```nginx
300+
server {
301+
gzip on;
302+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
303+
304+
listen 80;
305+
server_name _;
306+
index index.html;
307+
308+
location / {
309+
# content location
310+
root /app;
311+
312+
# exact matches -> reverse clean urls -> folders -> not found
313+
try_files $uri $uri.html $uri/ =404;
314+
315+
# non existent pages
316+
error_page 404 /404.html;
317+
318+
# a folder without index.html raises 403 in this setup
319+
error_page 403 /404.html;
320+
321+
# adjust caching headers
322+
# files in the assets folder have hashes filenames
323+
location ~* ^/assets/ {
324+
expires 1y;
325+
add_header Cache-Control "public, immutable";
326+
}
327+
}
328+
}
329+
```
330+
331+
本配置默认已构建的 VitePress 站点位于服务器上的 `/app` 目录中。如果站点文件位于其他位置,请相应调整 `root` 指令。
332+
333+
::: warning 不要默认为 index.html
334+
try_files 解析不能像其他 Vue 应用那样默认为 index.html。这会导致页面状态处于无效。
335+
:::
336+
337+
更多信息请参见 [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)。

Diff for: docs/zh/guide/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ $ bun vitepress init
8686
<<< @/snippets/init.ansi
8787

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

9292
## 文件结构 {#file-structure}

Diff for: docs/zh/guide/sitemap-generation.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
VitePress 提供开箱即用的配置,为站点生成 `sitemap.xml` 文件。要启用它,请将以下内容添加到 `.vitepress/config.js` 中:
44

55
```ts
6-
import { defineConfig } from 'vitepress'
7-
8-
export default defineConfig({
6+
export default {
97
sitemap: {
108
hostname: 'https://example.com'
119
}
12-
})
10+
}
1311
```
1412

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

2119
```ts
22-
import { defineConfig } from 'vitepress'
23-
24-
export default defineConfig({
20+
export default {
2521
sitemap: {
2622
hostname: 'https://example.com',
2723
lastmodDateOnly: false
2824
}
29-
})
25+
}
26+
```
27+
28+
如果在配置中使用 `base`,则应将其追加到 `hostname` 选项中:
29+
30+
```ts
31+
export default {
32+
base: '/my-site/',
33+
sitemap: {
34+
hostname: 'https://example.com/my-site/'
35+
}
36+
}
3037
```
3138

3239
## `transformItems` Hook
3340

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

3643
```ts
37-
import { defineConfig } from 'vitepress'
38-
39-
export default defineConfig({
44+
export default {
4045
sitemap: {
4146
hostname: 'https://example.com',
4247
transformItems: (items) => {
43-
// 添加新选项或修改/过滤现有选项
48+
// 添加新项目或修改/筛选现有选项
4449
items.push({
4550
url: '/extra-page',
4651
changefreq: 'monthly',
@@ -49,5 +54,5 @@ export default defineConfig({
4954
return items
5055
}
5156
}
52-
})
57+
}
5358
```

0 commit comments

Comments
 (0)