Skip to content

docs: describe useSite/usePage runtime hooks#2887

Merged
SoonIter merged 2 commits intomainfrom
copilot/add-documentation-for-hooks
Dec 12, 2025
Merged

docs: describe useSite/usePage runtime hooks#2887
SoonIter merged 2 commits intomainfrom
copilot/add-documentation-for-hooks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 12, 2025

The hooks useSite (normalized rspress.config.ts) and usePage (per-page MDX/Markdown metadata) lacked documentation.

  • Docs (EN/ZH): Added pages for useSite and usePage explaining returned data (normalized site config and parsed page metadata) with usage guidance.
  • Navigation: Included the new hooks in the hooks index metadata for both locales.
import { useSite, usePage } from '@rspress/core/runtime';

export default function Info() {
  const { site } = useSite();
  const { page } = usePage();
  return (
    <>
      <div>{site.title}</div>
      {page.lastUpdatedTime && <div>Updated: {page.lastUpdatedTime}</div>}
    </>
  );
}
Original prompt

根据 packages/runtime/src/hooks/useSite.ts 和 usePage.ts 撰写文档

useSite 返回一个 normalized 的 rspress.config.ts
usePage 返回当前页面经过 mdx 或 markdown parse 分析所提取的元信息


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 12, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit 7dfed04
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/693bfb465489520007d2764d
😎 Deploy Preview https://deploy-preview-2887--rspress-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: SoonIter <79413249+SoonIter@users.noreply.github.com>
Copilot AI changed the title [WIP] Add documentation for useSite and usePage hooks Docs: describe useSite/usePage runtime hooks Dec 12, 2025
Copilot AI requested a review from SoonIter December 12, 2025 11:25
@SoonIter SoonIter changed the title Docs: describe useSite/usePage runtime hooks docs: describe useSite/usePage runtime hooks Dec 12, 2025
@SoonIter SoonIter marked this pull request as ready for review December 12, 2025 14:36
Copilot AI review requested due to automatic review settings December 12, 2025 14:36
@github-actions
Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

📁 web

Path: website/doc_build/web/rsdoctor-data.json

📌 Baseline Commit: 5d394d4e14 | PR: #2885

Metric Current Baseline Change
📊 Total Size 14.5 MB 14.5 MB 34.9 KB (0.2%)
📄 JavaScript 13.9 MB 13.9 MB 32.2 KB (0.2%)
🎨 CSS 113.7 KB 113.7 KB 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 480.7 KB 478.0 KB 2.7 KB (0.6%)

📦 Download Diff Report: web Bundle Diff

Generated by Rsdoctor GitHub Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive documentation for two runtime hooks, useSite and usePage, which were previously undocumented. The useSite hook returns the normalized site configuration from rspress.config.ts, while usePage exposes metadata extracted from the current Markdown or MDX page.

  • Added English and Chinese documentation pages for both hooks
  • Included practical code examples demonstrating hook usage
  • Updated navigation metadata to include the new documentation pages

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
website/docs/en/ui/hooks/use-site.mdx Documents the useSite hook, explaining it returns normalized site configuration with examples
website/docs/en/ui/hooks/use-page.mdx Documents the usePage hook, showing how to access current page metadata
website/docs/zh/ui/hooks/use-site.mdx Chinese translation of useSite documentation
website/docs/zh/ui/hooks/use-page.mdx Chinese translation of usePage documentation
website/docs/en/ui/hooks/_meta.json Adds navigation entries for the new English hook documentation
website/docs/zh/ui/hooks/_meta.json Adds navigation entries for the new Chinese hook documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SoonIter SoonIter enabled auto-merge (squash) December 12, 2025 15:09
@SoonIter SoonIter merged commit d9c7e99 into main Dec 12, 2025
17 of 18 checks passed
@SoonIter SoonIter deleted the copilot/add-documentation-for-hooks branch December 12, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants