close
  • English
  • LastUpdated

    Warning

    This component is mainly used in conjunction with wrap/eject in Custom Theme , and is different from components that are directly imported in MDX. You can modify the styles and functions by passing component props or directly overriding the component. If you override the entire component through eject, please note that the reading of the corresponding configuration options of the component will become invalid and you need to control it yourself.

    LastUpdated displays the page's last updated time, and optionally the last author. Typically used with the theme's lastUpdated configuration.

    Usage

    Last Updated: 6/11/2026, 10:53:48 AM

    import { LastUpdated as BasicLastUpdated } from '@rspress/core/theme-original';
    
    export default function LastUpdated() {
      return <BasicLastUpdated />;
    }

    This component doesn't accept any props and automatically reads the last updated time from page metadata.

    Enable lastUpdated in rspress.config.ts:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      themeConfig: {
        lastUpdated: true,
      },
    });

    When lastUpdated is enabled, the component automatically reads and formats the page metadata.

    Displaying the author

    Configure lastUpdated.author to display the last commit author:

    rspress.config.ts
    export default defineConfig({
      themeConfig: {
        lastUpdated: {
          // Show the commit author's name:
          // author: true,
    
          // Or use custom display text:
          author: ({ name, email }) => `${name} <${email}>`,
        },
      },
    });

    The callback receives { name, email, filePath } (the commit author info from git log and the source file path) and returns the string to render.

    To customize the display text or time format, you can export and modify theme/components/LastUpdated/index.tsx using rspress eject LastUpdated.