@rspress/plugin-last-updated
is a plugin for displaying the last updated time in articles.
When you have configured lastUpdated: true
in the default theme, this plugin will be automatically activated.
npm add @rspress/plugin-last-updated -D
import { lastUpdated } from '@rspress/plugin-last-updated';
import { defineConfig } from 'rspress/config';
export default defineConfig({
plugins: [lastUpdated()],
});
After registering the plugin, you can get the last updated timestamp of the article at runtime. Here's an example:
import { usePageData } from 'rspress/runtime';
function MyComponent() {
const pageData = usePageData();
return <div>{pageData.page.lastUpdatedTime}</div>;
}