File tree 3 files changed +67
-14
lines changed
3 files changed +67
-14
lines changed Original file line number Diff line number Diff line change @@ -287,3 +287,51 @@ Cache-Control: max-age=31536000,immutable
287
287
# ## Kinsta 静态站点托管 {#kinsta-static-site-hosting}
288
288
289
289
你可以按照这些[说明](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)。
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ $ bun vitepress init
86
86
<<< @/snippets/init.ansi
87
87
88
88
:::tip Vue 作为 peer dependency
89
- 如果打算使用 Vue 组件或 API 进行自定义,还应该明确地将 ` vue ` 安装为 peer dependency。
89
+ 如果打算使用 Vue 组件或 API 进行自定义,还应该明确地将 ` vue ` 安装为 dependency。
90
90
:::
91
91
92
92
## 文件结构 {#file-structure}
Original file line number Diff line number Diff line change 3
3
VitePress 提供开箱即用的配置,为站点生成 ` sitemap.xml ` 文件。要启用它,请将以下内容添加到 ` .vitepress/config.js ` 中:
4
4
5
5
``` ts
6
- import { defineConfig } from ' vitepress'
7
-
8
- export default defineConfig ({
6
+ export default {
9
7
sitemap: {
10
8
hostname: ' https://example.com'
11
9
}
12
- })
10
+ }
13
11
```
14
12
15
13
要在 ` sitemap.xml ` 中包含 ` <lastmod> ` 标签,可以启用 [ ` lastUpdated ` ] ( ../reference/default-theme-last-updated ) 选项。
@@ -19,28 +17,35 @@ export default defineConfig({
19
17
VitePress 的 sitemap 由 [ ` sitemap ` ] ( https://www.npmjs.com/package/sitemap ) 模块提供支持。可以将该模块支持的选项传递给配置文件中的 ` sitemap ` 选项。这些选项将直接传递给 ` SitemapStream ` 构造函数。有关更多详细信息,请参阅 [ ` sitemap ` 文档] ( https://www.npmjs.com/package/sitemap#options-you-can-pass ) 。例如:
20
18
21
19
``` ts
22
- import { defineConfig } from ' vitepress'
23
-
24
- export default defineConfig ({
20
+ export default {
25
21
sitemap: {
26
22
hostname: ' https://example.com' ,
27
23
lastmodDateOnly: false
28
24
}
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
+ }
30
37
```
31
38
32
39
## ` transformItems ` Hook
33
40
34
41
在将 sitemap 写入 ` sitemap.xml ` 文件之前,可以使用 ` sitemap.transformItems ` 钩子来修改 sitemap。使用 sitemap 调用该钩子,应返回 sitemap 数组。例如:
35
42
36
43
``` ts
37
- import { defineConfig } from ' vitepress'
38
-
39
- export default defineConfig ({
44
+ export default {
40
45
sitemap: {
41
46
hostname: ' https://example.com' ,
42
47
transformItems : (items ) => {
43
- // 添加新选项或修改/过滤现有选项
48
+ // 添加新项目或修改/筛选现有选项
44
49
items .push ({
45
50
url: ' /extra-page' ,
46
51
changefreq: ' monthly' ,
@@ -49,5 +54,5 @@ export default defineConfig({
49
54
return items
50
55
}
51
56
}
52
- })
57
+ }
53
58
```
You can’t perform that action at this time.
0 commit comments