@rspress/plugin-last-updated
Introduction
@rspress/plugin-last-updated
is a plugin for displaying the last updated time in articles.
TIP
- When you have configured
lastUpdated: true
in the default theme, this plugin will be automatically activated. You don't need to install and register it manually.
- You need to commit the markdown file to see the updated time.
Installation
npm add @rspress/plugin-last-updated -D
Usage
1. Register the plugin
rspress.config.ts
import { pluginLastUpdated } from '@rspress/plugin-last-updated';
import { defineConfig } from 'rspress/config';
export default defineConfig({
plugins: [pluginLastUpdated()],
});
2. Access at runtime
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>;
}