# Add Last Updated Dates to a VitePress Blog

Yes. An agent turns on VitePress's git-based lastUpdated, shows it in your custom theme next to the publish date, guards against shallow clones, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-last-updated-dates/vitepress/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the theme before adding a date to it. In a blog laid out like vuejs/blog, `.vitepress/config.ts` sets the title, `cleanUrls: true`, a few `head` tags and `buildEnd: genFeed`, and nothing about `lastUpdated`. `.vitepress/theme/index.ts` exports only a `Layout`, so this is a custom theme rather than the default one: `Layout.vue` picks `Home.vue`, `NotFound.vue` or `Article.vue` from `frontmatter.index` and `page.isNotFound`. `Article.vue` finds the current post in the data from `posts.data.ts`, a `createContentLoader('posts/*.md')` that reads `frontmatter.date`, formats it, and sorts newest first; the header renders `<Date :date="date" />`, and `Date.vue` prints a `<time>` with an ISO `datetime` and the formatted string. Every post under `posts/` has `title`, `date`, `author`, `gravatar` and `twitter` in its frontmatter. `package.json` pins `vitepress` `^1.3.4` (1.3.4 in `pnpm-lock.yaml`), `pnpm@9.8.0`, Tailwind with the typography plugin, and the `feed` package for `genFeed.ts`.

VitePress's feature is one config option. With `lastUpdated: true` in `config.ts`, the build runs `git log -1 --pretty="%ai"` for each Markdown file and puts the timestamp on the page data, where a theme reads it as `page.lastUpdated` from `useData()`. It is not tied to the default theme; the value is there for any layout to use. The content loader in `posts.data.ts` does not carry it, so the home page list stays as it is and only `Article.vue` changes.

In `Article.vue` the agent adds a computed `updated` from `page.lastUpdated`, and renders a second line under the publish date, `Updated on`, only when the two dates differ by more than a day; otherwise every post would show an update on the day it was published, which is noise. It reuses `Date.vue` by passing the same `{ time, string }` shape the loader builds, using the same `toLocaleDateString('en-US', ...)` options as `posts.data.ts` so the two lines match. Because `tsconfig.json` is `strict`, the computed handles the `undefined` case for a file not yet committed, which is what a local `vitepress dev` sees for a draft. `genFeed.ts` is not changed; the feed's `date` stays the publish date.

The failure mode is the deploy. A shallow clone gives every file the same timestamp, the time of the clone, so every post shows the same update date. The repository builds with `vitepress build` from `package.json` and ships a `vercel.json`; the agent documents in the pull request that a platform cloning with limited depth needs full history, and, where the build script is the only hook available, prepends `git fetch --unshallow` to a `docs:build` script the way the VitePress docs describe. The agent checks the output by building in the sandbox from a full clone and reading one post's HTML for the two `<time>` elements with different `datetime` values.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add last updated dates to this VitePress blog. Read .vitepress/config.ts, .vitepress/theme/index.ts, Layout.vue, Article.vue, Date.vue, posts.data.ts, genFeed.ts, package.json, pnpm-lock.yaml, tsconfig.json, vercel.json and two posts under posts/ first. Set lastUpdated: true in config.ts. In Article.vue, read page.lastUpdated from useData, and when it is more than a day after the post's date, render an 'Updated on' line under the publish date using the existing Date.vue component and the same en-US formatting posts.data.ts uses; handle the case where lastUpdated has no value for an uncommitted file. Do not change genFeed.ts or the home page list. Build with pnpm install and pnpm build from the full clone, confirm one post's HTML has two time elements with different datetime values, and open a pull request that quotes the build output and explains what a shallow clone on the deploy platform would show and how to avoid it.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request changes `.vitepress/config.ts` (one option) and `.vitepress/theme/Article.vue` (one computed and one conditional block), and optionally `package.json` if a `git fetch --unshallow` build script was needed. Its description quotes the `vitepress build` output, shows the rendered header for one post that has been edited since publishing and one that has not, and has a short section on shallow clones with the exact platform setting or script change to make.

A reviewer checks that the comparison is against the post's `date` frontmatter rather than the build time, that the line is hidden when the dates are within a day, and that `genFeed.ts` still uses the publish date. They may want a different label than `Updated on`, which is a string in the template.

Once deployed from a full clone, each edited post shows when it last changed, taken from git rather than from a field someone has to remember to update.

## Run it on every pull request that edits a published post

An automation on the Project with a `github` trigger on `pull_request.opened` and `pull_request.synchronize` runs when a file under `posts/` changes. An automation's run is read-only; it builds the branch in its sandbox, reads the rendered header for the changed post and posts a review comment showing the updated date the merge will display, so the author sees that a typo fix will mark the post as revised and can decide whether that is wanted.

A company with several VitePress sites starts one run per site from a handler on its own server, sending this body to `POST /o/{org}/sessions` with the repository in `resources` and a `request_id` that is a UUID v5 of the repository name, so a retried loop returns the run it already started. Each run reads its own theme, since a site on the default theme needs only the config option and a `themeConfig.lastUpdated` entry rather than a template change.

## Why run it on Rush?

The feature is one line of config and one template change, and the thing that goes wrong is the environment: a shallow clone makes every date identical and nobody notices until the site is live. The agent builds from a full clone in its own sandbox, checks the HTML, and writes down the deploy caveat in the pull request with the command output kept beside it.

A custom theme means there is no default component to drop in. An agent that reads `Article.vue`, `Date.vue` and `posts.data.ts` reuses the formatting the blog already has instead of adding a second date style, and the reviewer sees exactly where the new line comes from.

## Frequently asked questions

### Where does the date come from?

From git. With `lastUpdated: true`, VitePress runs `git log -1 --pretty="%ai"` on each Markdown file at build time and exposes the result as `page.lastUpdated`. A file that is not committed has no value, which the template handles.

### Why does every post show the same date after deploying?

The deploy cloned the repository shallowly, so every file's last commit is the clone itself. On GitHub Actions the fix is `fetch-depth: 0` on the checkout step; elsewhere, prepend `git fetch --unshallow` to the build script. The pull request says which applies to this repository's setup.

### Will a typo fix mark an old post as updated?

Yes, because git does not distinguish a typo from a rewrite. The template hides the line when the update is within a day of publishing, and the review automation described above shows the author what the merged page will say before it is merged.

### Does this change the RSS feed?

No. `genFeed.ts` keeps using `frontmatter.date` for each item, so feed readers are not told a post is new when it was only edited. Adding an `updated` field to the feed would be a separate change.

## More VitePress jobs

- [Add Lighthouse CI to a VitePress Docs Site](https://getrush.ai/run/add-lighthouse-ci/vitepress/)
- [Add Link Checking to a VitePress Site](https://getrush.ai/run/add-link-checking/vitepress/)
- [Add llms.txt to a VitePress Blog](https://getrush.ai/run/add-llms-txt/vitepress/)

## The same job on other stacks

- [Show Last Updated Dates on a Zola Blog](https://getrush.ai/run/add-last-updated-dates/zola/)
- [Add Last Updated Dates to an mdBook Site](https://getrush.ai/run/add-last-updated-dates/mdbook/)
- [Show Last Updated Dates on MkDocs Pages](https://getrush.ai/run/add-last-updated-dates/mkdocs/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
