Skip to content

Commit 90f585a

Browse files
liangtongxiebrc-dd
andauthored
docs: add more detailed note in Last Updated reference (#4780)
--------- Co-authored-by: Divyansh Singh <[email protected]>
1 parent 801648a commit 90f585a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,27 @@
22

33
The update time of the last content will be displayed in the lower right corner of the page. To enable it, add `lastUpdated` options to your config.
44

5-
::: tip
6-
You need to commit the markdown file to see the updated time.
5+
::: info
6+
VitePress displays the "last updated" time using the timestamp of the most recent Git commit for each file. To enable this, the Markdown file must be committed to Git.
7+
8+
Internally, VitePress runs `git log -1 --pretty="%ai"` on each file to retrieve its timestamp. If all pages show the same update time, it's likely due to shallow cloning (common in CI environments), which limits Git history.
9+
10+
To fix this in **GitHub Actions**, use the following in your workflow:
11+
12+
```yaml{4}
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
```
18+
19+
Other CI/CD platforms have similar settings.
20+
21+
If such options aren't available, you can prepend the `docs:build` command in your `package.json` with a manual fetch:
22+
23+
```json
24+
"docs:build": "git fetch --unshallow && vitepress build docs"
25+
```
726
:::
827

928
## Site-Level Config

0 commit comments

Comments
 (0)