> For AI agents: the complete documentation index is available at https://rspress.rs/zh/llms.txt, the full documentation bundle is available at https://rspress.rs/zh/llms-full.txt.

# LastUpdated

`LastUpdated` 展示页面的最后更新时间，并可选择显示最后的作者。通常配合主题的 `lastUpdated` 配置使用。

## 用法

```tsx preview
import { LastUpdated as BasicLastUpdated } from '@rspress/core/theme-original';

export default function LastUpdated() {
  return <BasicLastUpdated />;
}
```

该组件不接受任何 props，会自动从页面元数据中读取最后更新时间。

## 相关配置

在 `rspress.config.ts` 中开启 `lastUpdated`：

```ts title="rspress.config.ts"
import { defineConfig } from '@rspress/core';

export default defineConfig({
  themeConfig: {
    lastUpdated: true,
  },
});
```

当启用 `lastUpdated` 时，组件会自动读取页面元数据并格式化显示。

### 显示作者

配置 `lastUpdated.author` 可以展示最后一次提交的作者：

```ts title="rspress.config.ts"
export default defineConfig({
  themeConfig: {
    lastUpdated: {
      // 展示提交作者名称：
      // author: true,

      // 或使用自定义展示文本：
      author: ({ name, email }) => `${name} <${email}>`,
    },
  },
});
```

回调函数会收到 `{ name, email, filePath }`（来自 `git log` 的作者信息以及源文件路径），返回值即为要展示的字符串。

如需自定义展示文案或时间格式，可通过 `rspress eject LastUpdated` 导出并修改 `theme/components/LastUpdated/index.tsx`。
