usePage
usePage provides metadata extracted from the current Markdown or MDX page, and is a core hook of Rspress.
- Type:
() => { page: PageDataLegacy['page'] }
The page object contains parsed frontmatter and runtime details such as title, toc, lang, version, routePath, pagePath, description, pageType, lastUpdatedTime, etc., making it easy to build contextual UI based on the current document.
Here is an example of getting the current page's title and description:
When you need to get both page metadata and global site configuration, use together with
useSite.