Skip to content

Commit ac5ddd3

Browse files
docs(zh): sync reference/default-theme-last-updated.md (#4974)
1 parent 113d230 commit ac5ddd3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/zh/reference/default-theme-last-updated.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@
33
最近一条内容的更新时间会显示在页面右下角。要启用它,请将 `lastUpdated` 选项添加到配置中。
44

55
::: tip
6-
你必须提交 markdown 文件才能看到最后更新时间。
6+
VitePress 通过每个文件最近一次 Git 提交的时间戳显示"最后更新"时间,因此你必须提交 markdown 文件才能看到最后更新时间。
7+
8+
具体实现上,VitePress 会对每个文件执行`git log -1 --pretty="%ai"`命令以获取时间戳。若所有页面显示相同的更新时间,可能是由于浅克隆(常见于 CI 环境)导致 Git 历史记录受限所致。
9+
10+
**GitHub Actions** 中修复此问题,请在工作流中添加以下配置:
11+
12+
```yaml{4}
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
```
18+
19+
其他 CI/CD 平台也有类似设置。
20+
21+
若上述选项不可用,可在 `package.json` 中的 `docs:build` 命令后手动添加获取操作:
22+
23+
```json
24+
"docs:build": "git fetch --unshallow && vitepress build docs"
25+
```
726
:::
827

928
## 全局配置 {#site-level-config}

0 commit comments

Comments
 (0)